]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/SnpDxe/Nvdata.c
BaseTools:Change the path of the file that Binary Cache
[mirror_edk2.git] / MdeModulePkg / Universal / Network / SnpDxe / Nvdata.c
index 20d5daa25cb2afbb58ac8e4329d11b4ba2e7140f..7010b63a540961330aa49879215094b5c7cf6d31 100644 (file)
@@ -1,15 +1,9 @@
 /** @file\r
-       Implementation of reading and writing operations on the NVRAM device\r
-       attached to a network interface.\r
\r
-Copyright (c) 2004 - 2009, Intel Corporation. <BR> \r
-All rights reserved. This program and the accompanying materials are licensed \r
-and made available under the terms and conditions of the BSD License which \r
-accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+   Implementation of reading and writing operations on the NVRAM device\r
+   attached to a network interface.\r
+\r
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -48,7 +42,7 @@ PxeNvDataRead (
   Snp->Cdb.CPBsize    = PXE_CPBSIZE_NOT_USED;\r
   Snp->Cdb.CPBaddr    = PXE_CPBADDR_NOT_USED;\r
 \r
-  Snp->Cdb.DBsize     = sizeof (PXE_DB_NVDATA);\r
+  Snp->Cdb.DBsize     = (UINT16) sizeof (PXE_DB_NVDATA);\r
   Snp->Cdb.DBaddr     = (UINT64)(UINTN) Db;\r
 \r
   Snp->Cdb.StatCode   = PXE_STATCODE_INITIALIZE;\r
@@ -88,60 +82,60 @@ PxeNvDataRead (
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
-  ASSERT ((Offset + BufferSize) <= sizeof (Db->Data));\r
+  ASSERT (Offset < sizeof (Db->Data));\r
 \r
-  CopyMem (Buffer, Db->Data.Byte + Offset, BufferSize);\r
+  CopyMem (Buffer, &Db->Data.Byte[Offset], BufferSize);\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
 \r
 /**\r
-  Performs read and write operations on the NVRAM device attached to a network \r
+  Performs read and write operations on the NVRAM device attached to a network\r
   interface.\r
-  \r
-  This function performs read and write operations on the NVRAM device attached \r
+\r
+  This function performs read and write operations on the NVRAM device attached\r
   to a network interface. If ReadWrite is TRUE, a read operation is performed.\r
-  If ReadWrite is FALSE, a write operation is performed. Offset specifies the \r
-  byte offset at which to start either operation. Offset must be a multiple of \r
-  NvRamAccessSize , and it must have a value between zero and NvRamSize. \r
+  If ReadWrite is FALSE, a write operation is performed. Offset specifies the\r
+  byte offset at which to start either operation. Offset must be a multiple of\r
+  NvRamAccessSize , and it must have a value between zero and NvRamSize.\r
   BufferSize specifies the length of the read or write operation. BufferSize must\r
   also be a multiple of NvRamAccessSize, and Offset + BufferSize must not exceed\r
-  NvRamSize. \r
-  If any of the above conditions is not met, then EFI_INVALID_PARAMETER will be \r
-  returned. \r
-  If all the conditions are met and the operation is "read," the NVRAM device \r
-  attached to the network interface will be read into Buffer and EFI_SUCCESS \r
+  NvRamSize.\r
+  If any of the above conditions is not met, then EFI_INVALID_PARAMETER will be\r
+  returned.\r
+  If all the conditions are met and the operation is "read," the NVRAM device\r
+  attached to the network interface will be read into Buffer and EFI_SUCCESS\r
   will be returned. If this is a write operation, the contents of Buffer will be\r
-  used to update the contents of the NVRAM device attached to the network \r
+  used to update the contents of the NVRAM device attached to the network\r
   interface and EFI_SUCCESS will be returned.\r
-  \r
+\r
   It does the basic checking on the input parameters and retrieves snp structure\r
   and then calls the read_nvdata() call which does the actual reading\r
 \r
   @param This       A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
   @param ReadWrite  TRUE for read operations, FALSE for write operations.\r
-  @param Offset     Byte offset in the NVRAM device at which to start the read or \r
-                    write operation. This must be a multiple of NvRamAccessSize \r
-                    and less than NvRamSize. (See EFI_SIMPLE_NETWORK_MODE)  \r
-  @param BufferSize The number of bytes to read or write from the NVRAM device. \r
+  @param Offset     Byte offset in the NVRAM device at which to start the read or\r
+                    write operation. This must be a multiple of NvRamAccessSize\r
+                    and less than NvRamSize. (See EFI_SIMPLE_NETWORK_MODE)\r
+  @param BufferSize The number of bytes to read or write from the NVRAM device.\r
                     This must also be a multiple of NvramAccessSize.\r
   @param Buffer     A pointer to the data buffer.\r
 \r
   @retval EFI_SUCCESS           The NVRAM access was performed.\r
   @retval EFI_NOT_STARTED       The network interface has not been started.\r
   @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
-                                * The This parameter is NULL \r
-                                * The This parameter does not point to a valid \r
+                                * The This parameter is NULL\r
+                                * The This parameter does not point to a valid\r
                                   EFI_SIMPLE_NETWORK_PROTOCOL  structure\r
-                                * The Offset parameter is not a multiple of \r
+                                * The Offset parameter is not a multiple of\r
                                   EFI_SIMPLE_NETWORK_MODE.NvRamAccessSize\r
-                                * The Offset parameter is not less than \r
+                                * The Offset parameter is not less than\r
                                   EFI_SIMPLE_NETWORK_MODE.NvRamSize\r
-                                * The BufferSize parameter is not a multiple of \r
+                                * The BufferSize parameter is not a multiple of\r
                                   EFI_SIMPLE_NETWORK_MODE.NvRamAccessSize\r
                                 * The Buffer parameter is NULL\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network \r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network\r
                                 interface.\r
   @retval EFI_UNSUPPORTED       This function is not supported by the network\r
                                 interface.\r