]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
UnixPkg: Allow build.sh/build64.sh to be run from the edk2 root
[mirror_edk2.git] / MdeModulePkg / Bus / Ata / AtaAtapiPassThru / AhciMode.c
index 71d58f6622c538649b97350bea7fba710eda353e..bc673973d7be2e60787d2865789db358fb70f20b 100644 (file)
@@ -135,11 +135,11 @@ AhciOrReg (
 /**\r
   Wait for memory set to the test value.\r
     \r
-  @param  PciIo      The PCI IO protocol instance.\r
-  @param  Offset         The memory address to test.\r
-  @param  MaskValue      The mask value of memory.\r
-  @param  TestValue      The test value of memory.\r
-  @param  Timeout        The time out value for wait memory set.\r
+  @param  PciIo             The PCI IO protocol instance.\r
+  @param  Offset            The memory address to test.\r
+  @param  MaskValue         The mask value of memory.\r
+  @param  TestValue         The test value of memory.\r
+  @param  Timeout           The time out value for wait memory set.\r
 \r
   @retval EFI_DEVICE_ERROR  The memory is not set.\r
   @retval EFI_TIMEOUT       The memory setting is time out.\r
@@ -188,8 +188,8 @@ AhciWaitMemSet (
   Check if the device is still on port. It also checks if the AHCI controller \r
   supports the address and data count will be transfered.\r
 \r
-  @param  PciIo      The PCI IO protocol instance.\r
-  @param  Port           The number of port.\r
+  @param  PciIo            The PCI IO protocol instance.\r
+  @param  Port             The number of port.\r
 \r
   @retval EFI_SUCCESS      The device is attached to port and the transfer data is \r
                            supported by AHCI controller.\r
@@ -347,15 +347,15 @@ AhciDisableFisReceive (
 /**\r
   Build the command list, command table and prepare the fis receiver.\r
     \r
-  @param    PciIo         The PCI IO protocol instance.\r
+  @param    PciIo                 The PCI IO protocol instance.\r
   @param    AhciRegisters         The pointer to the EFI_AHCI_REGISTERS.\r
-  @param    Port          The number of port.\r
-  @param    PortMultiplier    The timeout value of stop.\r
-  @param    CommandFis      The control fis will be used for the transfer.\r
-  @param    CommandList     The command list will be used for the transfer.\r
-  @param    AtapiCommand      The atapi command will be used for the transfer.\r
-  @param    AtapiCommandLength  The length of the atapi command.\r
-  @param    CommandSlotNumber   The command slot will be used for the transfer.\r
+  @param    Port                  The number of port.\r
+  @param    PortMultiplier        The timeout value of stop.\r
+  @param    CommandFis            The control fis will be used for the transfer.\r
+  @param    CommandList           The command list will be used for the transfer.\r
+  @param    AtapiCommand          The atapi command will be used for the transfer.\r
+  @param    AtapiCommandLength    The length of the atapi command.\r
+  @param    CommandSlotNumber     The command slot will be used for the transfer.\r
   @param    DataPhysicalAddr      The pointer to the data buffer pci bus master address.\r
   @param    DataLength            The data count to be transferred.\r
 \r
@@ -466,7 +466,7 @@ AhciBuildCommand (
 /**\r
   Buid a command FIS.\r
     \r
-  @param  CmdFis          A pointer to the EFI_AHCI_COMMAND_FIS data structure.\r
+  @param  CmdFis            A pointer to the EFI_AHCI_COMMAND_FIS data structure.\r
   @param  AtaCommandBlock   A pointer to the AhciBuildCommandFis data structure.\r
 \r
 **/\r
@@ -501,17 +501,17 @@ AhciBuildCommandFis (
   CmdFis->AhciCFisSecCount    = AtaCommandBlock->AtaSectorCount;\r
   CmdFis->AhciCFisSecCountExp = AtaCommandBlock->AtaSectorCountExp;\r
 \r
-  CmdFis->AhciCFisDevHead     = AtaCommandBlock->AtaDeviceHead | 0xE0;\r
+  CmdFis->AhciCFisDevHead     = (UINT8) (AtaCommandBlock->AtaDeviceHead | 0xE0);\r
 }\r
 \r
 /**\r
   Start a PIO data transfer on specific port.\r
     \r
-  @param  PciIo             The PCI IO protocol instance.\r
+  @param  PciIo               The PCI IO protocol instance.\r
   @param  AhciRegisters       The pointer to the EFI_AHCI_REGISTERS.\r
-  @param  Port              The number of port.\r
-  @param  PortMultiplier    The timeout value of stop.\r
-  @param  AtapiCommand      The atapi command will be used for the transfer.\r
+  @param  Port                The number of port.\r
+  @param  PortMultiplier      The timeout value of stop.\r
+  @param  AtapiCommand        The atapi command will be used for the transfer.\r
   @param  AtapiCommandLength  The length of the atapi command.\r
   @param  Read                The transfer direction.\r
   @param  AtaCommandBlock     The EFI_ATA_COMMAND_BLOCK data.\r
@@ -527,6 +527,7 @@ AhciBuildCommandFis (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 AhciPioTransfer (\r
   IN     EFI_PCI_IO_PROTOCOL        *PciIo,\r
   IN     EFI_AHCI_REGISTERS         *AhciRegisters,\r
@@ -691,23 +692,23 @@ Exit:
 /**\r
   Start a DMA data transfer on specific port\r
 \r
-  @param  PciIo         The PCI IO protocol instance.\r
-  @param  AhciRegisters         The pointer to the EFI_AHCI_REGISTERS.\r
-  @param  Port          The number of port.\r
+  @param  PciIo               The PCI IO protocol instance.\r
+  @param  AhciRegisters       The pointer to the EFI_AHCI_REGISTERS.\r
+  @param  Port                The number of port.\r
   @param  PortMultiplier      The timeout value of stop.\r
   @param  AtapiCommand        The atapi command will be used for the transfer.\r
-  @param  AtapiCommandLength    The length of the atapi command.\r
-  @param  Read                  The transfer direction.\r
-  @param  AtaCommandBlock       The EFI_ATA_COMMAND_BLOCK data.\r
-  @param  AtaStatusBlock        The EFI_ATA_STATUS_BLOCK data.\r
-  @param  MemoryAddr            The pointer to the data buffer.\r
-  @param  DataCount             The data count to be transferred.\r
-  @param  Timeout               The timeout value of non data transfer.\r
-\r
-  @retval EFI_DEVICE_ERROR  The DMA data transfer abort with error occurs.\r
-  @retval EFI_TIMEOUT     The operation is time out.\r
-  @retval EFI_UNSUPPORTED   The device is not ready for transfer.\r
-  @retval EFI_SUCCESS     The DMA data transfer executes successfully.\r
+  @param  AtapiCommandLength  The length of the atapi command.\r
+  @param  Read                The transfer direction.\r
+  @param  AtaCommandBlock     The EFI_ATA_COMMAND_BLOCK data.\r
+  @param  AtaStatusBlock      The EFI_ATA_STATUS_BLOCK data.\r
+  @param  MemoryAddr          The pointer to the data buffer.\r
+  @param  DataCount           The data count to be transferred.\r
+  @param  Timeout             The timeout value of non data transfer.\r
+\r
+  @retval EFI_DEVICE_ERROR    The DMA data transfer abort with error occurs.\r
+  @retval EFI_TIMEOUT         The operation is time out.\r
+  @retval EFI_UNSUPPORTED     The device is not ready for transfer.\r
+  @retval EFI_SUCCESS         The DMA data transfer executes successfully.\r
    \r
 **/\r
 EFI_STATUS\r
@@ -860,15 +861,15 @@ Exit:
 /**\r
   Start a non data transfer on specific port.\r
     \r
-  @param  PciIo             The PCI IO protocol instance.\r
-  @param  AhciRegisters         The pointer to the EFI_AHCI_REGISTERS.\r
-  @param  Port              The number of port.\r
+  @param  PciIo               The PCI IO protocol instance.\r
+  @param  AhciRegisters       The pointer to the EFI_AHCI_REGISTERS.\r
+  @param  Port                The number of port.\r
   @param  PortMultiplier      The timeout value of stop.\r
-  @param  AtapiCommand      The atapi command will be used for the transfer.\r
-  @param  AtapiCommandLength    The length of the atapi command.\r
-  @param    AtaCommandBlock       The EFI_ATA_COMMAND_BLOCK data.\r
-  @param    AtaStatusBlock        The EFI_ATA_STATUS_BLOCK data.\r
-  @param  Timeout               The timeout value of non data transfer.\r
+  @param  AtapiCommand        The atapi command will be used for the transfer.\r
+  @param  AtapiCommandLength  The length of the atapi command.\r
+  @param  AtaCommandBlock     The EFI_ATA_COMMAND_BLOCK data.\r
+  @param  AtaStatusBlock      The EFI_ATA_STATUS_BLOCK data.\r
+  @param  Timeout             The timeout value of non data transfer.\r
 \r
   @retval EFI_DEVICE_ERROR    The non data transfer abort with error occurs.\r
   @retval EFI_TIMEOUT         The operation is time out.\r
@@ -1251,11 +1252,11 @@ AhciReset (
 /**\r
   Send Buffer cmd to specific device.\r
     \r
-  @param  PciIo             The PCI IO protocol instance.\r
-  @param  AhciRegisters         The pointer to the EFI_AHCI_REGISTERS.\r
-  @param  Port              The number of port.\r
+  @param  PciIo               The PCI IO protocol instance.\r
+  @param  AhciRegisters       The pointer to the EFI_AHCI_REGISTERS.\r
+  @param  Port                The number of port.\r
   @param  PortMultiplier      The timeout value of stop.\r
-  @param    Buffer                The data buffer to store IDENTIFY PACKET data.\r
+  @param  Buffer              The data buffer to store IDENTIFY PACKET data.\r
 \r
   @retval EFI_DEVICE_ERROR    The cmd abort with error occurs.\r
   @retval EFI_TIMEOUT         The operation is time out.\r
@@ -1308,11 +1309,11 @@ AhciIdentify (
 /**\r
   Send Buffer cmd to specific device.\r
     \r
-  @param  PciIo             The PCI IO protocol instance.\r
-  @param  AhciRegisters         The pointer to the EFI_AHCI_REGISTERS.\r
-  @param  Port              The number of port.\r
+  @param  PciIo               The PCI IO protocol instance.\r
+  @param  AhciRegisters       The pointer to the EFI_AHCI_REGISTERS.\r
+  @param  Port                The number of port.\r
   @param  PortMultiplier      The timeout value of stop.\r
-  @param    Buffer                The data buffer to store IDENTIFY PACKET data.\r
+  @param  Buffer              The data buffer to store IDENTIFY PACKET data.\r
 \r
   @retval EFI_DEVICE_ERROR    The cmd abort with error occurs.\r
   @retval EFI_TIMEOUT         The operation is time out.\r
@@ -1365,12 +1366,12 @@ AhciIdentifyPacket (
 /**\r
   Send SET FEATURE cmd on specific device.\r
     \r
-  @param  PciIo             The PCI IO protocol instance.\r
-  @param  AhciRegisters         The pointer to the EFI_AHCI_REGISTERS.\r
-  @param  Port              The number of port.\r
+  @param  PciIo               The PCI IO protocol instance.\r
+  @param  AhciRegisters       The pointer to the EFI_AHCI_REGISTERS.\r
+  @param  Port                The number of port.\r
   @param  PortMultiplier      The timeout value of stop.\r
-  @param    Feature               The data to send Feature register.\r
-  @param  FeatureSpecificData   The specific data for SET FEATURE cmd.\r
+  @param  Feature             The data to send Feature register.\r
+  @param  FeatureSpecificData The specific data for SET FEATURE cmd.\r
 \r
   @retval EFI_DEVICE_ERROR    The cmd abort with error occurs.\r
   @retval EFI_TIMEOUT         The operation is time out.\r
@@ -1561,7 +1562,7 @@ AhciCreateTransferDescriptor (
   // Get the number of command slots per port supported by this HBA.\r
   //\r
   MaxCommandSlotNumber = (UINT8) (((Capability & 0x1F00) >> 8) + 1);\r
-  Support64Bit         = ((Capability & BIT31) != 0) ? TRUE : FALSE;\r
+  Support64Bit         = (BOOLEAN) (((Capability & BIT31) != 0) ? TRUE : FALSE);\r
 \r
   MaxReceiveFisSize    = MaxPortNumber * sizeof (EFI_AHCI_RECEIVED_FIS);\r
   Status = PciIo->AllocateBuffer (\r
@@ -1588,7 +1589,7 @@ AhciCreateTransferDescriptor (
                     EfiPciIoOperationBusMasterCommonBuffer,\r
                     Buffer,\r
                     &Bytes,\r
-                    &(EFI_PHYSICAL_ADDRESS)AhciRegisters->AhciRFisPciAddr,\r
+                    (EFI_PHYSICAL_ADDRESS *) &AhciRegisters->AhciRFisPciAddr,\r
                     &AhciRegisters->MapRFis\r
                     );\r
 \r
@@ -1600,7 +1601,7 @@ AhciCreateTransferDescriptor (
     goto Error6;\r
   }\r
 \r
-  if ((!Support64Bit) && ((EFI_PHYSICAL_ADDRESS)AhciRegisters->AhciRFisPciAddr > 0x100000000UL)) {\r
+  if ((!Support64Bit) && ((EFI_PHYSICAL_ADDRESS)(UINTN)AhciRegisters->AhciRFisPciAddr > 0x100000000ULL)) {\r
     //\r
     // The AHCI HBA doesn't support 64bit addressing, so should not get a >4G pci bus master address.\r
     //\r
@@ -1642,7 +1643,7 @@ AhciCreateTransferDescriptor (
                     EfiPciIoOperationBusMasterCommonBuffer,\r
                     Buffer,\r
                     &Bytes,\r
-                    &(EFI_PHYSICAL_ADDRESS)AhciRegisters->AhciCmdListPciAddr,\r
+                    (EFI_PHYSICAL_ADDRESS *)&AhciRegisters->AhciCmdListPciAddr,\r
                     &AhciRegisters->MapCmdList\r
                     );\r
 \r
@@ -1654,7 +1655,7 @@ AhciCreateTransferDescriptor (
     goto Error4;\r
   }\r
 \r
-  if ((!Support64Bit) && ((EFI_PHYSICAL_ADDRESS)AhciRegisters->AhciCmdListPciAddr > 0x100000000UL)) {\r
+  if ((!Support64Bit) && ((EFI_PHYSICAL_ADDRESS)(UINTN)AhciRegisters->AhciCmdListPciAddr > 0x100000000ULL)) {\r
     //\r
     // The AHCI HBA doesn't support 64bit addressing, so should not get a >4G pci bus master address.\r
     //\r
@@ -1697,7 +1698,7 @@ AhciCreateTransferDescriptor (
                     EfiPciIoOperationBusMasterCommonBuffer,\r
                     Buffer,\r
                     &Bytes,\r
-                    &(EFI_PHYSICAL_ADDRESS)AhciRegisters->AhciCommandTablePciAddr,\r
+                    (EFI_PHYSICAL_ADDRESS *)&AhciRegisters->AhciCommandTablePciAddr,\r
                     &AhciRegisters->MapCommandTable\r
                     );\r
 \r
@@ -1709,7 +1710,7 @@ AhciCreateTransferDescriptor (
     goto Error2;\r
   }\r
 \r
-  if ((!Support64Bit) && ((EFI_PHYSICAL_ADDRESS)AhciRegisters->AhciCommandTablePciAddr > 0x100000000UL)) {\r
+  if ((!Support64Bit) && ((EFI_PHYSICAL_ADDRESS)(UINTN)AhciRegisters->AhciCommandTablePciAddr > 0x100000000ULL)) {\r
     //\r
     // The AHCI HBA doesn't support 64bit addressing, so should not get a >4G pci bus master address.\r
     //\r
@@ -1819,7 +1820,7 @@ AhciModeInitialization (
   // Get the number of command slots per port supported by this HBA.\r
   //\r
   MaxCommandSlotNumber = (UINT8) (((Capability & 0x1F00) >> 8) + 1);\r
-  Support64Bit         = ((Capability & BIT31) != 0) ? TRUE : FALSE;\r
+  Support64Bit         = (BOOLEAN) (((Capability & BIT31) != 0) ? TRUE : FALSE);\r
 \r
   //\r
   // Get the bit map of those ports exposed by this HBA.\r
@@ -1942,7 +1943,7 @@ AhciModeInitialization (
         } else {\r
           continue;\r
         }\r
-    \r
+\r
         DEBUG ((EFI_D_INFO, "port [%d] port mulitplier [%d] has a [%a]\n", \r
             Port, 0, DeviceType == EfiIdeCdrom ? "cdrom" : "harddisk"));\r
 \r
@@ -1991,7 +1992,7 @@ AhciModeInitialization (
         }\r
 \r
         Status = AhciDeviceSetFeature (PciIo, AhciRegisters, Port, 0, 0x03, (UINT32)(*(UINT8 *)&TransferMode));\r
-    \r
+\r
         if (EFI_ERROR (Status)) {\r
           DEBUG ((EFI_D_ERROR, "Set transfer Mode Fail, Status = %r\n", Status));\r
           continue;\r
@@ -2006,5 +2007,3 @@ AhciModeInitialization (
   return EFI_SUCCESS;\r
 }\r
 \r
-\r
-\r