]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/XenBusDxe/XenBus.c
OvmfPkg: replace old EFI_D_ debug levels with new DEBUG_ ones
[mirror_edk2.git] / OvmfPkg / XenBusDxe / XenBus.c
index a569cfa088fa44406f282e74680185aac50f1df0..f8a41b6d363203e33ec15588c3096c7532504357 100644 (file)
@@ -1,5 +1,5 @@
 /** @file\r
-  XenBus Bus driver implemtation.\r
+  XenBus Bus driver implementation.\r
 \r
   This file implement the necessary to discover and enumerate Xen PV devices\r
   through XenStore.\r
   This file may be distributed separately from the Linux kernel, or\r
   incorporated into other software packages, subject to the following license:\r
 \r
-  Permission is hereby granted, free of charge, to any person obtaining a copy\r
-  of this source file (the "Software"), to deal in the Software without\r
-  restriction, including without limitation the rights to use, copy, modify,\r
-  merge, publish, distribute, sublicense, and/or sell copies of the Software,\r
-  and to permit persons to whom the Software is furnished to do so, subject to\r
-  the following conditions:\r
-\r
-  The above copyright notice and this permission notice shall be included in\r
-  all copies or substantial portions of the Software.\r
-\r
-  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
-  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
-  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
-  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
-  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\r
-  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\r
-  IN THE SOFTWARE.\r
+  SPDX-License-Identifier: MIT\r
 **/\r
 \r
 #include <Library/PrintLib.h>\r
 STATIC XENBUS_PRIVATE_DATA gXenBusPrivateData;\r
 \r
 STATIC XENBUS_DEVICE_PATH gXenBusDevicePathTemplate = {\r
-  .Vendor.Header.Type = HARDWARE_DEVICE_PATH,\r
-  .Vendor.Header.SubType = HW_VENDOR_DP,\r
-  .Vendor.Header.Length[0] = (UINT8) sizeof (XENBUS_DEVICE_PATH),\r
-  .Vendor.Header.Length[1] = (UINT8) (sizeof (XENBUS_DEVICE_PATH) >> 8),\r
-  .Vendor.Guid = XENBUS_PROTOCOL_GUID,\r
-  .Type = 0,\r
-  .DeviceId = 0\r
+  {                                                 // Vendor\r
+    {                                               // Vendor.Header\r
+      HARDWARE_DEVICE_PATH,                         // Vendor.Header.Type\r
+      HW_VENDOR_DP,                                 // Vendor.Header.SubType\r
+      {\r
+        (UINT8) (sizeof (XENBUS_DEVICE_PATH)),      // Vendor.Header.Length[0]\r
+        (UINT8) (sizeof (XENBUS_DEVICE_PATH) >> 8), // Vendor.Header.Length[1]\r
+      }\r
+    },\r
+    XENBUS_PROTOCOL_GUID,                           // Vendor.Guid\r
+  },\r
+  0,                                                // Type\r
+  0                                                 // DeviceId\r
 };\r
 \r
 \r
@@ -132,7 +122,7 @@ XenBusAddDevice (
   XENBUS_PRIVATE_DATA *Private;\r
   EFI_STATUS Status;\r
   XENBUS_DEVICE_PATH *TempXenBusPath;\r
-  VOID *ChildPciIo;\r
+  VOID *ChildXenIo;\r
 \r
   AsciiSPrint (DevicePath, sizeof (DevicePath),\r
                "device/%a/%a", Type, Id);\r
@@ -158,7 +148,7 @@ XenBusAddDevice (
        * happen if a device is going away after\r
        * switching to Closed.\r
        */\r
-      DEBUG ((EFI_D_INFO, "XenBus: Device %a ignored. "\r
+      DEBUG ((DEBUG_INFO, "XenBus: Device %a ignored. "\r
               "State %d\n", DevicePath, State));\r
       Status = EFI_SUCCESS;\r
       goto out;\r
@@ -167,7 +157,7 @@ XenBusAddDevice (
     StatusXenStore = XenStoreRead (XST_NIL, DevicePath, "backend",\r
                                    NULL, (VOID **) &BackendPath);\r
     if (StatusXenStore != XENSTORE_STATUS_SUCCESS) {\r
-      DEBUG ((EFI_D_ERROR, "xenbus: %a no backend path.\n", DevicePath));\r
+      DEBUG ((DEBUG_ERROR, "xenbus: %a no backend path.\n", DevicePath));\r
       Status = EFI_NOT_FOUND;\r
       goto out;\r
     }\r
@@ -176,7 +166,7 @@ XenBusAddDevice (
     Private->XenBusIo.Type = AsciiStrDup (Type);\r
     Private->XenBusIo.Node = AsciiStrDup (DevicePath);\r
     Private->XenBusIo.Backend = BackendPath;\r
-    Private->XenBusIo.DeviceId = AsciiStrDecimalToUintn (Id);\r
+    Private->XenBusIo.DeviceId = (UINT16)AsciiStrDecimalToUintn (Id);\r
     Private->Dev = Dev;\r
 \r
     TempXenBusPath = AllocateCopyPool (sizeof (XENBUS_DEVICE_PATH),\r
@@ -202,17 +192,17 @@ XenBusAddDevice (
     }\r
 \r
     Status = gBS->OpenProtocol (Dev->ControllerHandle,\r
-               &gEfiPciIoProtocolGuid,\r
-               &ChildPciIo, Dev->This->DriverBindingHandle,\r
+               &gXenIoProtocolGuid,\r
+               &ChildXenIo, Dev->This->DriverBindingHandle,\r
                Private->Handle,\r
                EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER);\r
     if (EFI_ERROR (Status)) {\r
-      DEBUG ((EFI_D_ERROR, "open by child controller fail (%r)\n",\r
+      DEBUG ((DEBUG_ERROR, "open by child controller fail (%r)\n",\r
               Status));\r
       goto ErrorOpenProtocolByChild;\r
     }\r
   } else {\r
-    DEBUG ((EFI_D_ERROR, "XenBus: does not exist: %a\n", DevicePath));\r
+    DEBUG ((DEBUG_ERROR, "XenBus: does not exist: %a\n", DevicePath));\r
     Status = EFI_NOT_FOUND;\r
   }\r
 \r
@@ -220,7 +210,7 @@ XenBusAddDevice (
 \r
 ErrorOpenProtocolByChild:\r
   gBS->UninstallMultipleProtocolInterfaces (\r
-    &Private->Handle,\r
+    Private->Handle,\r
     &gEfiDevicePathProtocolGuid, Private->DevicePath,\r
     &gXenBusProtocolGuid, &Private->XenBusIo,\r
     NULL);\r
@@ -268,7 +258,7 @@ XenBusEnumerateDeviceType (
     XenBusAddDevice (Dev, Type, Directory[Index]);\r
   }\r
 \r
-  FreePool (Directory);\r
+  FreePool ((VOID*)Directory);\r
 }\r
 \r
 \r
@@ -304,7 +294,7 @@ XenBusEnumerateBus (
     XenBusEnumerateDeviceType (Dev, Types[Index]);\r
   }\r
 \r
-  FreePool (Types);\r
+  FreePool ((VOID*)Types);\r
 \r
   return XENSTORE_STATUS_SUCCESS;\r
 }\r
@@ -322,7 +312,7 @@ XenBusSetState (
   XENSTORE_STATUS Status;\r
   CHAR8 *Temp;\r
 \r
-  DEBUG ((EFI_D_INFO, "XenBus: Set state to %d\n", NewState));\r
+  DEBUG ((DEBUG_INFO, "XenBus: Set state to %d\n", NewState));\r
 \r
   Status = XenStoreRead (Transaction, This->Node, "state", NULL, (VOID **)&Temp);\r
   if (Status != XENSTORE_STATUS_SUCCESS) {\r
@@ -338,38 +328,43 @@ XenBusSetState (
     Status = XenStoreSPrint (Transaction, This->Node, "state", "%d", NewState);\r
   } while (Status == XENSTORE_STATUS_EAGAIN);\r
   if (Status != XENSTORE_STATUS_SUCCESS) {\r
-    DEBUG ((EFI_D_ERROR, "XenBus: failed to write new state\n"));\r
+    DEBUG ((DEBUG_ERROR, "XenBus: failed to write new state\n"));\r
     goto Out;\r
   }\r
-  DEBUG ((EFI_D_INFO, "XenBus: Set state to %d, done\n", NewState));\r
+  DEBUG ((DEBUG_INFO, "XenBus: Set state to %d, done\n", NewState));\r
 \r
 Out:\r
   return Status;\r
 }\r
 \r
 STATIC XENBUS_PRIVATE_DATA gXenBusPrivateData = {\r
-  .Signature = XENBUS_PRIVATE_DATA_SIGNATURE,\r
-\r
-  .XenBusIo.XsRead = XenBusXenStoreRead,\r
-  .XenBusIo.XsBackendRead = XenBusXenStoreBackendRead,\r
-  .XenBusIo.XsPrintf = XenBusXenStoreSPrint,\r
-  .XenBusIo.XsRemove = XenBusXenStoreRemove,\r
-  .XenBusIo.XsTransactionStart = XenBusXenStoreTransactionStart,\r
-  .XenBusIo.XsTransactionEnd = XenBusXenStoreTransactionEnd,\r
-  .XenBusIo.SetState = XenBusSetState,\r
-  .XenBusIo.GrantAccess = XenBusGrantAccess,\r
-  .XenBusIo.GrantEndAccess = XenBusGrantEndAccess,\r
-  .XenBusIo.EventChannelAllocate = XenBusEventChannelAllocate,\r
-  .XenBusIo.EventChannelNotify = XenBusEventChannelNotify,\r
-  .XenBusIo.EventChannelClose = XenBusEventChannelClose,\r
-  .XenBusIo.RegisterWatch = XenBusRegisterWatch,\r
-  .XenBusIo.RegisterWatchBackend = XenBusRegisterWatchBackend,\r
-  .XenBusIo.UnregisterWatch = XenBusUnregisterWatch,\r
-  .XenBusIo.WaitForWatch = XenBusWaitForWatch,\r
-\r
-  .XenBusIo.Type = NULL,\r
-  .XenBusIo.Node = NULL,\r
-  .XenBusIo.Backend = NULL,\r
-\r
-  .Dev = NULL\r
+  XENBUS_PRIVATE_DATA_SIGNATURE,    // Signature\r
+  { NULL, NULL },                   // Link\r
+  NULL,                             // Handle\r
+  {                                 // XenBusIo\r
+    XenBusXenStoreRead,             // XenBusIo.XsRead\r
+    XenBusXenStoreBackendRead,      // XenBusIo.XsBackendRead\r
+    XenBusXenStoreSPrint,           // XenBusIo.XsPrintf\r
+    XenBusXenStoreRemove,           // XenBusIo.XsRemove\r
+    XenBusXenStoreTransactionStart, // XenBusIo.XsTransactionStart\r
+    XenBusXenStoreTransactionEnd,   // XenBusIo.XsTransactionEnd\r
+    XenBusSetState,                 // XenBusIo.SetState\r
+    XenBusGrantAccess,              // XenBusIo.GrantAccess\r
+    XenBusGrantEndAccess,           // XenBusIo.GrantEndAccess\r
+    XenBusEventChannelAllocate,     // XenBusIo.EventChannelAllocate\r
+    XenBusEventChannelNotify,       // XenBusIo.EventChannelNotify\r
+    XenBusEventChannelClose,        // XenBusIo.EventChannelClose\r
+    XenBusRegisterWatch,            // XenBusIo.RegisterWatch\r
+    XenBusRegisterWatchBackend,     // XenBusIo.RegisterWatchBackend\r
+    XenBusUnregisterWatch,          // XenBusIo.UnregisterWatch\r
+    XenBusWaitForWatch,             // XenBusIo.WaitForWatch\r
+\r
+    NULL,                           // XenBusIo.Type\r
+    0,                              // XenBusIo.DeviceId\r
+    NULL,                           // XenBusIo.Node\r
+    NULL,                           // XenBusIo.Backend\r
+  },\r
+\r
+  NULL,                             // Dev\r
+  NULL                              // DevicePath\r
 };\r