diff mbox series

[edk2,edk2-platforms,v1,06/14] Hisilicon D03/D05: Open SnpPlatform source code

Message ID 1516287703-35516-7-git-send-email-huangming23@huawei.com
State New
Headers show
Series Improve D0x platforms and bug fix | expand

Commit Message

gary guo Jan. 18, 2018, 3:01 p.m. UTC
From: Jason Zhang <zhangjinsong2@huawei.com>


1. Open driver source code.
2. This code includes network sequence correction
   solution.

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                           |  3 +-
 Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.c      | 99 ++++++++++++++++++++
 Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.h      | 43 +++++++++
 Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf    | 60 ++++++++++++
 Silicon/Hisilicon/HisiPkg.dec                            |  1 +
 Silicon/Hisilicon/Include/Protocol/SnpPlatformProtocol.h | 32 +++++++
 9 files changed, 241 insertions(+), 3 deletions(-)

-- 
1.9.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Comments

Ard Biesheuvel Jan. 20, 2018, 11 a.m. UTC | #1
On 18 January 2018 at 15:01, Ming Huang <heyi.guo@linaro.org> wrote:
> From: Jason Zhang <zhangjinsong2@huawei.com>

>

> 1. Open driver source code.

> 2. This code includes network sequence correction

>    solution.

>

> 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                           |  3 +-

>  Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.c      | 99 ++++++++++++++++++++

>  Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.h      | 43 +++++++++

>  Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf    | 60 ++++++++++++

>  Silicon/Hisilicon/HisiPkg.dec                            |  1 +

>  Silicon/Hisilicon/Include/Protocol/SnpPlatformProtocol.h | 32 +++++++

>  9 files changed, 241 insertions(+), 3 deletions(-)

>

> diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc

> index 370e17b..b22afe3 100644

> --- a/Platform/Hisilicon/D03/D03.dsc

> +++ b/Platform/Hisilicon/D03/D03.dsc

> @@ -404,6 +404,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 6e43228..e93985b 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 0d19909..4e19de2 100644

> --- a/Platform/Hisilicon/D05/D05.dsc

> +++ b/Platform/Hisilicon/D05/D05.dsc

> @@ -541,6 +541,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 9edc679..9873677 100644

> --- a/Platform/Hisilicon/D05/D05.fdf

> +++ b/Platform/Hisilicon/D05/D05.fdf

> @@ -247,8 +247,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..385c04a

> --- /dev/null

> +++ b/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.c

> @@ -0,0 +1,99 @@

> +/** @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 "SnpPlatform.h"

> +


STATIC

> + HISI_PLATFORM_SNP_PROTOCOL mSnpPlatformProtocol[] = {

> +  {

> +    4,

> +    1

> +  },

> +  {

> +    5,

> +    1

> +  },

> +  {

> +    2,

> +    0

> +  },

> +  {

> +    3,

> +    0

> +  },

> +  {

> +    0,

> +    1

> +  },

> + {

> +    1,

> +    1

> +  },

> +  {

> +    6,

> +    0

> +  },

> +  {

> +    7,

> +    0

> +  }

> +};

> +

> +#define SNP_CONTROLLER_NUMBER             sizeof (mSnpPlatformProtocol) / sizeof (HISI_PLATFORM_SNP_PROTOCOL)

> +


ARRAY_SIZE()

> +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 < SNP_CONTROLLER_NUMBER; 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, "[%a]:[%dL] InstallProtocolInterface fail. %r\n", __FUNCTION__, __LINE__, Status));


Line length

And don't return an error from a loop like this: see the comment in
reply to the previous patch

> +      return Status;

> +    }

> +  }

> +

> +  DEBUG ((DEBUG_INFO,"SnpPlatformInitialize succes!\n"));

> +

> +  return EFI_SUCCESS;

> +}

> diff --git a/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.h b/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.h

> new file mode 100644

> index 0000000..031c8d3

> --- /dev/null

> +++ b/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.h

> @@ -0,0 +1,43 @@

> +/** @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_H_

> +#define _SNP_PLATFORM_H_

> +

> +#include <Uefi.h>

> +#include <PiDxe.h>

> +#include <Protocol/SnpPlatformProtocol.h>

> +#include <Guid/EventGroup.h>

> +#include <Library/ArmLib.h>

> +#include <Library/BaseMemoryLib.h>

> +#include <Library/BaseLib.h>

> +#include <Library/DebugLib.h>

> +#include <Library/DxeServicesTableLib.h>

> +#include <Library/IoLib.h>

> +#include <Library/MemoryAllocationLib.h>

> +#include <Library/PcdLib.h>

> +#include <Library/ReportStatusCodeLib.h>

> +#include <Library/UefiBootServicesTableLib.h>

> +#include <Library/UefiDriverEntryPoint.h>

> +#include <Library/UefiLib.h>

> +

> +typedef struct {

> +  UINTN                      Signature;

> +  EFI_HANDLE                 Handle;

> +  HISI_PLATFORM_SNP_PROTOCOL SnpPlatformProtocol;

> +} SNP_PLATFORM_INSTANCE;

> +#endif


You can move all of this into the .c file

> diff --git a/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf b/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf

> new file mode 100644

> index 0000000..804224b

> --- /dev/null

> +++ b/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf

> @@ -0,0 +1,60 @@

> +#/** @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.h

> +  SnpPlatform.c

> +

> +[Packages]

> +  ArmPkg/ArmPkg.dec


??

> +  MdePkg/MdePkg.dec

> +  MdeModulePkg/MdeModulePkg.dec

> +  Silicon/Hisilicon/HisiPkg.dec

> +

> +[FeaturePcd]

> +

> +

> +[LibraryClasses]

> +  ArmLib

> +  BaseLib

> +  BaseMemoryLib

> +  CacheMaintenanceLib

> +  DebugLib

> +  DxeServicesTableLib

> +  IoLib

> +  MemoryAllocationLib

> +  PlatformSysCtrlLib

> +  PcdLib

> +  ReportStatusCodeLib

> +  UefiLib

> +  UefiBootServicesTableLib

> +  UefiDriverEntryPoint

> +


Same question as before: are you really using all of these?
> +[Guids]

> +

> +[Protocols]

> +  gHisiSnpPlatformProtocolGuid

> +

> +[Depex]

> +  TRUE

> +

> diff --git a/Silicon/Hisilicon/HisiPkg.dec b/Silicon/Hisilicon/HisiPkg.dec

> index 9fa94fd..2bb6518 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

>

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Huangming (Mark) Jan. 23, 2018, 11:01 a.m. UTC | #2
On 2018/1/20 19:00, Ard Biesheuvel wrote:
> On 18 January 2018 at 15:01, Ming Huang <heyi.guo@linaro.org> wrote:

>> From: Jason Zhang <zhangjinsong2@huawei.com>

>>

>> 1. Open driver source code.

>> 2. This code includes network sequence correction

>>    solution.

>>

>> 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                           |  3 +-

>>  Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.c      | 99 ++++++++++++++++++++

>>  Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.h      | 43 +++++++++

>>  Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf    | 60 ++++++++++++

>>  Silicon/Hisilicon/HisiPkg.dec                            |  1 +

>>  Silicon/Hisilicon/Include/Protocol/SnpPlatformProtocol.h | 32 +++++++

>>  9 files changed, 241 insertions(+), 3 deletions(-)

>>

>> diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc

>> index 370e17b..b22afe3 100644

>> --- a/Platform/Hisilicon/D03/D03.dsc

>> +++ b/Platform/Hisilicon/D03/D03.dsc

>> @@ -404,6 +404,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 6e43228..e93985b 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 0d19909..4e19de2 100644

>> --- a/Platform/Hisilicon/D05/D05.dsc

>> +++ b/Platform/Hisilicon/D05/D05.dsc

>> @@ -541,6 +541,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 9edc679..9873677 100644

>> --- a/Platform/Hisilicon/D05/D05.fdf

>> +++ b/Platform/Hisilicon/D05/D05.fdf

>> @@ -247,8 +247,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..385c04a

>> --- /dev/null

>> +++ b/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.c

>> @@ -0,0 +1,99 @@

>> +/** @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 "SnpPlatform.h"

>> +

> 

> STATIC

> 

>> + HISI_PLATFORM_SNP_PROTOCOL mSnpPlatformProtocol[] = {

>> +  {

>> +    4,

>> +    1

>> +  },

>> +  {

>> +    5,

>> +    1

>> +  },

>> +  {

>> +    2,

>> +    0

>> +  },

>> +  {

>> +    3,

>> +    0

>> +  },

>> +  {

>> +    0,

>> +    1

>> +  },

>> + {

>> +    1,

>> +    1

>> +  },

>> +  {

>> +    6,

>> +    0

>> +  },

>> +  {

>> +    7,

>> +    0

>> +  }

>> +};

>> +

>> +#define SNP_CONTROLLER_NUMBER             sizeof (mSnpPlatformProtocol) / sizeof (HISI_PLATFORM_SNP_PROTOCOL)

>> +

> 

> ARRAY_SIZE()

> 

>> +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 < SNP_CONTROLLER_NUMBER; 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, "[%a]:[%dL] InstallProtocolInterface fail. %r\n", __FUNCTION__, __LINE__, Status));

> 

> Line length

> 

> And don't return an error from a loop like this: see the comment in

> reply to the previous patch

> 

>> +      return Status;

>> +    }

>> +  }

>> +

>> +  DEBUG ((DEBUG_INFO,"SnpPlatformInitialize succes!\n"));

>> +

>> +  return EFI_SUCCESS;

>> +}

>> diff --git a/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.h b/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.h

>> new file mode 100644

>> index 0000000..031c8d3

>> --- /dev/null

>> +++ b/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.h

>> @@ -0,0 +1,43 @@

>> +/** @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_H_

>> +#define _SNP_PLATFORM_H_

>> +

>> +#include <Uefi.h>

>> +#include <PiDxe.h>

>> +#include <Protocol/SnpPlatformProtocol.h>

>> +#include <Guid/EventGroup.h>

>> +#include <Library/ArmLib.h>

>> +#include <Library/BaseMemoryLib.h>

>> +#include <Library/BaseLib.h>

>> +#include <Library/DebugLib.h>

>> +#include <Library/DxeServicesTableLib.h>

>> +#include <Library/IoLib.h>

>> +#include <Library/MemoryAllocationLib.h>

>> +#include <Library/PcdLib.h>

>> +#include <Library/ReportStatusCodeLib.h>

>> +#include <Library/UefiBootServicesTableLib.h>

>> +#include <Library/UefiDriverEntryPoint.h>

>> +#include <Library/UefiLib.h>

>> +

>> +typedef struct {

>> +  UINTN                      Signature;

>> +  EFI_HANDLE                 Handle;

>> +  HISI_PLATFORM_SNP_PROTOCOL SnpPlatformProtocol;

>> +} SNP_PLATFORM_INSTANCE;

>> +#endif

> 

> You can move all of this into the .c file

> 

>> diff --git a/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf b/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf

>> new file mode 100644

>> index 0000000..804224b

>> --- /dev/null

>> +++ b/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf

>> @@ -0,0 +1,60 @@

>> +#/** @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.h

>> +  SnpPlatform.c

>> +

>> +[Packages]

>> +  ArmPkg/ArmPkg.dec

> 

> ??

> 

>> +  MdePkg/MdePkg.dec

>> +  MdeModulePkg/MdeModulePkg.dec

>> +  Silicon/Hisilicon/HisiPkg.dec

>> +

>> +[FeaturePcd]

>> +

>> +

>> +[LibraryClasses]

>> +  ArmLib

>> +  BaseLib

>> +  BaseMemoryLib

>> +  CacheMaintenanceLib

>> +  DebugLib

>> +  DxeServicesTableLib

>> +  IoLib

>> +  MemoryAllocationLib

>> +  PlatformSysCtrlLib

>> +  PcdLib

>> +  ReportStatusCodeLib

>> +  UefiLib

>> +  UefiBootServicesTableLib

>> +  UefiDriverEntryPoint

>> +

> 

> Same question as before: are you really using all of these?


There are some Libs which are not using.
I will delete it.

>> +[Guids]

>> +

>> +[Protocols]

>> +  gHisiSnpPlatformProtocolGuid

>> +

>> +[Depex]

>> +  TRUE

>> +

>> diff --git a/Silicon/Hisilicon/HisiPkg.dec b/Silicon/Hisilicon/HisiPkg.dec

>> index 9fa94fd..2bb6518 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

>>

> 

> .

> 


-- 
Best Regards,

Ming

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Leif Lindholm Jan. 23, 2018, 2:07 p.m. UTC | #3
On Thu, Jan 18, 2018 at 11:01:35PM +0800, Ming Huang wrote:
> From: Jason Zhang <zhangjinsong2@huawei.com>

> 

> 1. Open driver source code.


Please describe what this driver does.

> 2. This code includes network sequence correction

>    solution.


Which correction?
Is there an existing bug report somewhere this can refer to?
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Huangming (Mark) Jan. 24, 2018, 12:31 p.m. UTC | #4
On 2018/1/23 22:07, Leif Lindholm wrote:
> On Thu, Jan 18, 2018 at 11:01:35PM +0800, Ming Huang wrote:

>> From: Jason Zhang <zhangjinsong2@huawei.com>

>>

>> 1. Open driver source code.

> 

> Please describe what this driver does.

> 

>> 2. This code includes network sequence correction

>>    solution.

> 

> Which correction?

> Is there an existing bug report somewhere this can refer to?

> 

> .

> 


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

Thanks.

-- 
Best Regards,

Ming

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Leif Lindholm Jan. 24, 2018, 1:47 p.m. UTC | #5
On Wed, Jan 24, 2018 at 08:31:38PM +0800, Huangming (Mark) wrote:
> On 2018/1/23 22:07, Leif Lindholm wrote:

> > On Thu, Jan 18, 2018 at 11:01:35PM +0800, Ming Huang wrote:

> >> From: Jason Zhang <zhangjinsong2@huawei.com>

> >>

> >> 1. Open driver source code.

> > 

> > Please describe what this driver does.

> > 

> >> 2. This code includes network sequence correction

> >>    solution.

> > 

> > Which correction?

> > Is there an existing bug report somewhere this can refer to?

> > 

> > .

> > 

> 

> 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


Yes, that works - please add in v2.

/
    Leif
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox series

Patch

diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc
index 370e17b..b22afe3 100644
--- a/Platform/Hisilicon/D03/D03.dsc
+++ b/Platform/Hisilicon/D03/D03.dsc
@@ -404,6 +404,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 6e43228..e93985b 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 0d19909..4e19de2 100644
--- a/Platform/Hisilicon/D05/D05.dsc
+++ b/Platform/Hisilicon/D05/D05.dsc
@@ -541,6 +541,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 9edc679..9873677 100644
--- a/Platform/Hisilicon/D05/D05.fdf
+++ b/Platform/Hisilicon/D05/D05.fdf
@@ -247,8 +247,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..385c04a
--- /dev/null
+++ b/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.c
@@ -0,0 +1,99 @@ 
+/** @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 "SnpPlatform.h"
+
+ HISI_PLATFORM_SNP_PROTOCOL mSnpPlatformProtocol[] = {
+  {
+    4,
+    1
+  },
+  {
+    5,
+    1
+  },
+  {
+    2,
+    0
+  },
+  {
+    3,
+    0
+  },
+  {
+    0,
+    1
+  },
+ {
+    1,
+    1
+  },
+  {
+    6,
+    0
+  },
+  {
+    7,
+    0
+  }
+};
+
+#define SNP_CONTROLLER_NUMBER             sizeof (mSnpPlatformProtocol) / sizeof (HISI_PLATFORM_SNP_PROTOCOL)
+
+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 < SNP_CONTROLLER_NUMBER; 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, "[%a]:[%dL] InstallProtocolInterface fail. %r\n", __FUNCTION__, __LINE__, Status));
+      return Status;
+    }
+  }
+
+  DEBUG ((DEBUG_INFO,"SnpPlatformInitialize succes!\n"));
+
+  return EFI_SUCCESS;
+}
diff --git a/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.h b/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.h
new file mode 100644
index 0000000..031c8d3
--- /dev/null
+++ b/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.h
@@ -0,0 +1,43 @@ 
+/** @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_H_
+#define _SNP_PLATFORM_H_
+
+#include <Uefi.h>
+#include <PiDxe.h>
+#include <Protocol/SnpPlatformProtocol.h>
+#include <Guid/EventGroup.h>
+#include <Library/ArmLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/DxeServicesTableLib.h>
+#include <Library/IoLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PcdLib.h>
+#include <Library/ReportStatusCodeLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/UefiLib.h>
+
+typedef struct {
+  UINTN                      Signature;
+  EFI_HANDLE                 Handle;
+  HISI_PLATFORM_SNP_PROTOCOL SnpPlatformProtocol;
+} SNP_PLATFORM_INSTANCE;
+#endif
diff --git a/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf b/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf
new file mode 100644
index 0000000..804224b
--- /dev/null
+++ b/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf
@@ -0,0 +1,60 @@ 
+#/** @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.h
+  SnpPlatform.c
+
+[Packages]
+  ArmPkg/ArmPkg.dec
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  Silicon/Hisilicon/HisiPkg.dec
+
+[FeaturePcd]
+
+
+[LibraryClasses]
+  ArmLib
+  BaseLib
+  BaseMemoryLib
+  CacheMaintenanceLib
+  DebugLib
+  DxeServicesTableLib
+  IoLib
+  MemoryAllocationLib
+  PlatformSysCtrlLib
+  PcdLib
+  ReportStatusCodeLib
+  UefiLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+
+[Guids]
+
+[Protocols]
+  gHisiSnpPlatformProtocolGuid
+
+[Depex]
+  TRUE
+
diff --git a/Silicon/Hisilicon/HisiPkg.dec b/Silicon/Hisilicon/HisiPkg.dec
index 9fa94fd..2bb6518 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