]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/SnpDxe/Snp.c
1). Fix the debug level for DEBUG macro
[mirror_edk2.git] / MdeModulePkg / Universal / Network / SnpDxe / Snp.c
index 80a05f102f90f261a92c74d50c9661c126f38ec3..58451608e5737f30be2cc7f719068f1233b06ae1 100644 (file)
@@ -24,10 +24,14 @@ V2P                         *mV2p = NULL; // undi3.0 map_list head
 \r
 \r
 /**\r
-  Unsupport currently.\r
+  Send command to UNDI. It does nothing currently.\r
   \r
   @param Cdb   command to be sent to UNDI.\r
-\r
+   \r
+  @retval EFI_INVALID_PARAMETER  The command is 0. \r
+  @retval EFI_UNSUPPORTED        Default return status because it's not \r
+                                 supported currently.\r
+   \r
 **/\r
 EFI_STATUS\r
 IssueHwUndiCommand (\r
@@ -53,8 +57,8 @@ IssueHwUndiCommand (
   @param  Buffer               Pointer to buffer.\r
   @param  Length               Length of buffer in bytes.\r
 \r
-  @return 8-bit checksum of all bytes in buffer.\r
-  @return If ptr is NULL or len is zero, zero is returned.\r
+  @return 8-bit checksum of all bytes in buffer, or zero if ptr is NULL or len \r
+          is zero.\r
 \r
 **/\r
 UINT8\r
@@ -89,13 +93,13 @@ Calc8BitCksum (
   Supported() it must also follow these calling restrictions.\r
 \r
   @param  This                Protocol instance pointer.\r
-  @param  ControllerHandle    Handle of device to test\r
+  @param  ControllerHandle    Handle of device to test.\r
   @param  RemainingDevicePath Optional parameter use to pick a specific child\r
                               device to start.\r
 \r
-  @retval EFI_SUCCESS         This driver supports this device\r
-  @retval EFI_ALREADY_STARTED This driver is already running on this device\r
-  @retval other               This driver does not support this device\r
+  @retval EFI_SUCCESS         This driver supports this device.\r
+  @retval EFI_ALREADY_STARTED This driver is already running on this device.\r
+  @retval other               This driver does not support this device.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -151,7 +155,7 @@ SimpleNetworkDriverSupported (
   // Check to see if !PXE structure is valid. Paragraph alignment of !PXE structure is required.\r
   //\r
   if (NiiProtocol->ID & 0x0F) {\r
-    DEBUG ((EFI_D_NET, "\n!PXE structure is not paragraph aligned.\n"));\r
+    DEBUG ((EFI_D_ERROR | EFI_D_NET, "\n!PXE structure is not paragraph aligned.\n"));\r
     Status = EFI_UNSUPPORTED;\r
     goto Done;\r
   }\r
@@ -162,25 +166,25 @@ SimpleNetworkDriverSupported (
   //  Verify !PXE revisions.\r
   //\r
   if (Pxe->hw.Signature != PXE_ROMID_SIGNATURE) {\r
-    DEBUG ((EFI_D_NET, "\n!PXE signature is not valid.\n"));\r
+    DEBUG ((EFI_D_ERROR | EFI_D_NET, "\n!PXE signature is not valid.\n"));\r
     Status = EFI_UNSUPPORTED;\r
     goto Done;\r
   }\r
 \r
   if (Pxe->hw.Rev < PXE_ROMID_REV) {\r
-    DEBUG ((EFI_D_NET, "\n!PXE.Rev is not supported.\n"));\r
+    DEBUG ((EFI_D_ERROR | EFI_D_NET, "\n!PXE.Rev is not supported.\n"));\r
     Status = EFI_UNSUPPORTED;\r
     goto Done;\r
   }\r
 \r
   if (Pxe->hw.MajorVer < PXE_ROMID_MAJORVER) {\r
 \r
-    DEBUG ((EFI_D_NET, "\n!PXE.MajorVer is not supported.\n"));\r
+    DEBUG ((EFI_D_ERROR | EFI_D_NET, "\n!PXE.MajorVer is not supported.\n"));\r
     Status = EFI_UNSUPPORTED;\r
     goto Done;\r
 \r
   } else if (Pxe->hw.MajorVer == PXE_ROMID_MAJORVER && Pxe->hw.MinorVer < PXE_ROMID_MINORVER) {\r
-    DEBUG ((EFI_D_NET, "\n!PXE.MinorVer is not supported."));\r
+    DEBUG ((EFI_D_ERROR | EFI_D_NET, "\n!PXE.MinorVer is not supported."));\r
     Status = EFI_UNSUPPORTED;\r
     goto Done;\r
   }\r
@@ -189,13 +193,13 @@ SimpleNetworkDriverSupported (
   //\r
   if ((Pxe->hw.Implementation & PXE_ROMID_IMP_HW_UNDI) == 0) {\r
     if (Pxe->sw.EntryPoint < Pxe->sw.Len) {\r
-      DEBUG ((EFI_D_NET, "\n!PXE S/W entry point is not valid."));\r
+      DEBUG ((EFI_D_ERROR | EFI_D_NET, "\n!PXE S/W entry point is not valid."));\r
       Status = EFI_UNSUPPORTED;\r
       goto Done;\r
     }\r
 \r
     if (Pxe->sw.BusCnt == 0) {\r
-      DEBUG ((EFI_D_NET, "\n!PXE.BusCnt is zero."));\r
+      DEBUG ((EFI_D_ERROR | EFI_D_NET, "\n!PXE.BusCnt is zero."));\r
       Status = EFI_UNSUPPORTED;\r
       goto Done;\r
     }\r
@@ -254,7 +258,7 @@ SimpleNetworkDriverStart (
   UINT8                                     BarIndex;\r
   PXE_STATFLAGS                             InitStatFlags;\r
 \r
-  DEBUG ((EFI_D_NET, "\nSnpNotifyNetworkInterfaceIdentifier()  "));\r
+  DEBUG ((EFI_D_INFO, "\nSnpNotifyNetworkInterfaceIdentifier()  "));\r
 \r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
@@ -316,7 +320,7 @@ SimpleNetworkDriverStart (
   Pxe = (PXE_UNDI *) (UINTN) (Nii->ID);\r
 \r
   if (Calc8BitCksum (Pxe, Pxe->hw.Len) != 0) {\r
-    DEBUG ((EFI_D_NET, "\n!PXE checksum is not correct.\n"));\r
+    DEBUG ((EFI_D_ERROR | EFI_D_NET, "\n!PXE checksum is not correct.\n"));\r
     goto NiiError;\r
   }\r
 \r
@@ -331,7 +335,7 @@ SimpleNetworkDriverStart (
     //  broadcast support or we cannot do DHCP!\r
     //\r
   } else {\r
-    DEBUG ((EFI_D_NET, "\nUNDI does not have promiscuous or broadcast support."));\r
+    DEBUG ((EFI_D_ERROR | EFI_D_NET, "\nUNDI does not have promiscuous or broadcast support."));\r
     goto NiiError;\r
   }\r
   //\r
@@ -348,7 +352,7 @@ SimpleNetworkDriverStart (
                         );\r
 \r
   if (Status != EFI_SUCCESS) {\r
-    DEBUG ((EFI_D_NET, "\nCould not allocate SNP_DRIVER structure.\n"));\r
+    DEBUG ((EFI_D_ERROR | EFI_D_NET, "\nCould not allocate SNP_DRIVER structure.\n"));\r
     goto NiiError;\r
   }\r
 \r
@@ -422,7 +426,7 @@ SimpleNetworkDriverStart (
                         );\r
 \r
   if (Status != EFI_SUCCESS) {\r
-    DEBUG ((EFI_D_NET, "\nCould not allocate CPB and DB structures.\n"));\r
+    DEBUG ((EFI_D_ERROR | EFI_D_NET, "\nCould not allocate CPB and DB structures.\n"));\r
     goto Error_DeleteSNP;\r
   }\r
 \r
@@ -464,7 +468,7 @@ SimpleNetworkDriverStart (
   Snp->Cdb.IFnum      = Snp->IfNum;\r
   Snp->Cdb.Control    = PXE_CONTROL_LAST_CDB_IN_LIST;\r
 \r
-  DEBUG ((EFI_D_NET, "\nSnp->undi.get_init_info()  "));\r
+  DEBUG ((EFI_D_INFO | EFI_D_NET, "\nSnp->undi.get_init_info()  "));\r
 \r
   (*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);\r
 \r
@@ -474,7 +478,7 @@ SimpleNetworkDriverStart (
   InitStatFlags = Snp->Cdb.StatFlags;\r
 \r
   if (Snp->Cdb.StatCode != PXE_STATCODE_SUCCESS) {\r
-    DEBUG ((EFI_D_NET, "\nSnp->undi.init_info()  %xh:%xh\n", Snp->Cdb.StatFlags, Snp->Cdb.StatCode));\r
+    DEBUG ((EFI_D_ERROR | EFI_D_NET, "\nSnp->undi.init_info()  %xh:%xh\n", Snp->Cdb.StatFlags, Snp->Cdb.StatCode));\r
     PxeStop (Snp);\r
     goto Error_DeleteSNP;\r
   }\r
@@ -494,12 +498,12 @@ SimpleNetworkDriverStart (
   Snp->Cdb.IFnum      = Snp->IfNum;\r
   Snp->Cdb.Control    = PXE_CONTROL_LAST_CDB_IN_LIST;\r
 \r
-  DEBUG ((EFI_D_NET, "\nSnp->undi.get_config_info()  "));\r
+  DEBUG ((EFI_D_INFO | EFI_D_NET, "\nSnp->undi.get_config_info()  "));\r
 \r
   (*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);\r
 \r
   if (Snp->Cdb.StatCode != PXE_STATCODE_SUCCESS) {\r
-    DEBUG ((EFI_D_NET, "\nSnp->undi.config_info()  %xh:%xh\n", Snp->Cdb.StatFlags, Snp->Cdb.StatCode));\r
+    DEBUG ((EFI_D_ERROR | EFI_D_NET, "\nSnp->undi.config_info()  %xh:%xh\n", Snp->Cdb.StatFlags, Snp->Cdb.StatCode));\r
     PxeStop (Snp);\r
     goto Error_DeleteSNP;\r
   }\r
@@ -609,7 +613,7 @@ SimpleNetworkDriverStart (
   Status = PxeGetStnAddr (Snp);\r
 \r
   if (Status != EFI_SUCCESS) {\r
-    DEBUG ((EFI_D_ERROR, "\nSnp->undi.get_station_addr()  failed.\n"));\r
+    DEBUG ((EFI_D_ERROR, "\nSnp->undi.get_station_addr() failed.\n"));\r
     PxeShutdown (Snp);\r
     PxeStop (Snp);\r
     goto Error_DeleteSNP;\r
@@ -811,27 +815,27 @@ AddV2P (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  *V2p = AllocatePool (sizeof (V2P  ));\r
+  *V2p = AllocatePool (sizeof (V2P));\r
   if (*V2p != NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
   Status = mPciIo->Map (\r
-                        mPciIo,\r
-                        Type,\r
-                        VirtualAddress,\r
-                        &BufferSize,\r
-                        &(*V2p)->PhysicalAddress,\r
-                        &(*V2p)->Unmap\r
-                        );\r
+                     mPciIo,\r
+                     Type,\r
+                     VirtualAddress,\r
+                     &BufferSize,\r
+                     &(*V2p)->PhysicalAddress,\r
+                     &(*V2p)->Unmap\r
+                     );\r
   if (Status != EFI_SUCCESS) {\r
     FreePool (*V2p);\r
     return Status;\r
   }\r
   (*V2p)->VirtualAddress = VirtualAddress;\r
-  (*V2p)->BufferSize = BufferSize;\r
-  (*V2p)->Next  = mV2p;\r
-  mV2p          = *V2p;\r
+  (*V2p)->BufferSize     = BufferSize;\r
+  (*V2p)->Next           = mV2p;\r
+  mV2p                   = *V2p;\r
 \r
   return EFI_SUCCESS;\r
 }\r
@@ -846,8 +850,8 @@ AddV2P (
   @param  VirtualAddr          virtual address (or CPU address) to be searched in\r
                                the map list\r
 \r
-  @retval EFI_SUCEESS          if a match found!\r
-  @retval Other                match not found\r
+  @retval EFI_SUCEESS          A match was found.\r
+  @retval Other                A match cannot be found.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -874,13 +878,13 @@ FindV2p (
 \r
 \r
 /**\r
-  This routine unmaps the given virtual address and frees the memory allocated\r
-  for the map list node corresponding to that address.\r
+  Unmap the given virtual address and free the memory allocated for the map list\r
+  node corresponding to that address.\r
 \r
-  @param  VirtualAddress       virtual address (or CPU address) to be unmapped\r
+  @param  VirtualAddress       virtual address (or CPU address) to be unmapped.\r
 \r
-  @retval EFI_SUCEESS          if successfully unmapped\r
-  @retval Other                as indicated by the error\r
+  @retval EFI_SUCEESS          Successfully unmapped.\r
+  @retval Other                Other errors as indicated.\r
 \r
 **/\r
 EFI_STATUS\r