Porting ScsiBus module for Nt32Pkg.
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 29 Jun 2007 03:33:17 +0000 (03:33 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 29 Jun 2007 03:33:17 +0000 (03:33 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2876 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Bus/Scsi/ScsiBusDxe/ComponentName.c [new file with mode: 0644]
MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c [new file with mode: 0644]
MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.h [new file with mode: 0644]
MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.inf [new file with mode: 0644]
MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.msa [new file with mode: 0644]
MdeModulePkg/MdeModulePkg.dsc
Nt32Pkg/Nt32.dsc

diff --git a/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ComponentName.c b/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ComponentName.c
new file mode 100644 (file)
index 0000000..444ca44
--- /dev/null
@@ -0,0 +1,159 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which 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
+\r
+Module Name:\r
+\r
+  ComponentName.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiDxe.h>\r
+\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Protocol/ScsiPassThru.h>\r
+#include <Protocol/ScsiIo.h>\r
+#include <Protocol/ComponentName.h>\r
+#include <Protocol/DriverBinding.h>\r
+#include <Protocol/DevicePath.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/ScsiLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DevicePathLib.h>\r
+\r
+\r
+#include "ScsiBus.h"\r
+\r
+//\r
+// EFI Component Name Protocol\r
+//\r
+EFI_COMPONENT_NAME_PROTOCOL     gScsiBusComponentName = {\r
+  ScsiBusComponentNameGetDriverName,\r
+  ScsiBusComponentNameGetControllerName,\r
+  "eng"\r
+};\r
+\r
+static EFI_UNICODE_STRING_TABLE mScsiBusDriverNameTable[] = {\r
+  { "eng", (CHAR16 *) L"SCSI Bus Driver" },\r
+  { NULL , NULL }\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ScsiBusComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
+\r
+  Arguments:\r
+    This       - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    Language   - A pointer to a three character ISO 639-2 language identifier.\r
+                 This is the language of the driver name that that the caller \r
+                 is requesting, and it must match one of the languages specified\r
+                 in SupportedLanguages.  The number of languages supported by a \r
+                 driver is up to the driver writer.\r
+    DriverName - A pointer to the Unicode string to return.  This Unicode string\r
+                 is the name of the driver specified by This in the language \r
+                 specified by Language.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The Unicode string for the Driver specified by This\r
+                            and the language specified by Language was returned \r
+                            in DriverName.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - DriverName is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+\r
+--*/\r
+{\r
+  return LookupUnicodeString (\r
+          Language,\r
+          gScsiBusComponentName.SupportedLanguages,\r
+          mScsiBusDriverNameTable,\r
+          DriverName\r
+          );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ScsiBusComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                           *Language,\r
+  OUT CHAR16                                          **ControllerName\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieves a Unicode string that is the user readable name of the controller\r
+    that is being managed by an EFI Driver.\r
+\r
+  Arguments:\r
+    This             - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    ControllerHandle - The handle of a controller that the driver specified by \r
+                       This is managing.  This handle specifies the controller \r
+                       whose name is to be returned.\r
+    ChildHandle      - The handle of the child controller to retrieve the name \r
+                       of.  This is an optional parameter that may be NULL.  It \r
+                       will be NULL for device drivers.  It will also be NULL \r
+                       for a bus drivers that wish to retrieve the name of the \r
+                       bus controller.  It will not be NULL for a bus driver \r
+                       that wishes to retrieve the name of a child controller.\r
+    Language         - A pointer to a three character ISO 639-2 language \r
+                       identifier.  This is the language of the controller name \r
+                       that that the caller is requesting, and it must match one\r
+                       of the languages specified in SupportedLanguages.  The \r
+                       number of languages supported by a driver is up to the \r
+                       driver writer.\r
+    ControllerName   - A pointer to the Unicode string to return.  This Unicode\r
+                       string is the name of the controller specified by \r
+                       ControllerHandle and ChildHandle in the language \r
+                       specified by Language from the point of view of the \r
+                       driver specified by This. \r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The Unicode string for the user readable name in the\r
+                            language specified by Language for the driver \r
+                            specified by This was returned in DriverName.\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r
+                            EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - ControllerName is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This is not currently \r
+                            managing the controller specified by \r
+                            ControllerHandle and ChildHandle.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+\r
+--*/\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
diff --git a/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c b/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c
new file mode 100644 (file)
index 0000000..dc28be8
--- /dev/null
@@ -0,0 +1,788 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which 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
+\r
+Module Name:\r
+\r
+    scsibus.c\r
+    \r
+Abstract: \r
+    \r
+\r
+Revision History\r
+--*/\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiDxe.h>\r
+\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Protocol/ScsiPassThru.h>\r
+#include <Protocol/ScsiIo.h>\r
+#include <Protocol/ComponentName.h>\r
+#include <Protocol/DriverBinding.h>\r
+#include <Protocol/DevicePath.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/ScsiLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DevicePathLib.h>\r
+\r
+#include "ScsiBus.h"\r
+\r
+EFI_DRIVER_BINDING_PROTOCOL gSCSIBusDriverBinding = {\r
+  SCSIBusDriverBindingSupported,\r
+  SCSIBusDriverBindingStart,\r
+  SCSIBusDriverBindingStop,\r
+  0xa,\r
+  NULL,\r
+  NULL\r
+};\r
+\r
+/**\r
+  The user Entry Point for module ScsiBus. The user code starts with this function.\r
+\r
+  @param[in] ImageHandle    The firmware allocated handle for the EFI image.  \r
+  @param[in] SystemTable    A pointer to the EFI System Table.\r
+  \r
+  @retval EFI_SUCCESS       The entry point is executed successfully.\r
+  @retval other             Some error occurs when executing this entry point.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeScsiBus(\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+\r
+  //\r
+  // Install driver model protocol(s).\r
+  //\r
+  Status = EfiLibInstallAllDriverProtocols (\r
+             ImageHandle,\r
+             SystemTable,\r
+             &gSCSIBusDriverBinding,\r
+             ImageHandle,\r
+             &gScsiBusComponentName,\r
+             NULL,\r
+             NULL\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SCSIBusDriverBindingSupported (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN EFI_HANDLE                   Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  )\r
+/*++\r
+  \r
+  Routine Description:\r
+  \r
+  Arguments:\r
+  \r
+  Returns:\r
+  \r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+// TODO:    Controller - add argument and description to function comment\r
+// TODO:    RemainingDevicePath - add argument and description to function comment\r
+// TODO:    EFI_UNSUPPORTED - add return value to function comment\r
+// TODO:    EFI_UNSUPPORTED - add return value to function comment\r
+// TODO:    EFI_SUCCESS - add return value to function comment\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // If RemainingDevicePath is not NULL, it should verify that the first device\r
+  // path node in RemainingDevicePath is an ATAPI Device path node.\r
+  //\r
+  if (RemainingDevicePath != NULL) {\r
+    if ((RemainingDevicePath->Type != MESSAGING_DEVICE_PATH) ||\r
+        (RemainingDevicePath->SubType != MSG_ATAPI_DP) ||\r
+        (DevicePathNodeLength (RemainingDevicePath) != sizeof(ATAPI_DEVICE_PATH))) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+  }\r
+  //\r
+  // check for the existence of SCSI Pass Thru Protocol\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiScsiPassThruProtocolGuid,\r
+                  NULL,\r
+                  This->DriverBindingHandle,\r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SCSIBusDriverBindingStart (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN EFI_HANDLE                   Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  )\r
+/*++\r
+  \r
+  Routine Description:\r
+  \r
+  Arguments:\r
+  \r
+  Returns:\r
+  \r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+// TODO:    Controller - add argument and description to function comment\r
+// TODO:    RemainingDevicePath - add argument and description to function comment\r
+{\r
+  EFI_STATUS                  Status;\r
+  EFI_DEVICE_PATH_PROTOCOL    *ParentDevicePath;\r
+  EFI_SCSI_PASS_THRU_PROTOCOL *ScsiPassThru;\r
+  UINT32                      StartPun;\r
+  UINT64                      StartLun;\r
+  UINT32                      Pun;\r
+  UINT64                      Lun;\r
+  BOOLEAN                     ScanOtherPuns;\r
+\r
+  StartPun  = 0;\r
+  StartLun  = 0;\r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **) &ParentDevicePath,\r
+                  This->DriverBindingHandle,\r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Consume SCSI Pass Thru protocol.\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiScsiPassThruProtocolGuid,\r
+                  (VOID **) &ScsiPassThru,\r
+                  This->DriverBindingHandle,\r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
+    gBS->CloseProtocol (\r
+          Controller,\r
+          &gEfiDevicePathProtocolGuid,\r
+          This->DriverBindingHandle,\r
+          Controller\r
+          );\r
+    return Status;\r
+  }\r
+\r
+  if (RemainingDevicePath == NULL) {\r
+    StartPun  = 0xFFFFFFFF;\r
+    StartLun  = 0;\r
+  } else {\r
+    ScsiPassThru->GetTargetLun (ScsiPassThru, RemainingDevicePath, &StartPun, &StartLun);\r
+  }\r
+\r
+  for (Pun = StartPun, ScanOtherPuns = TRUE; ScanOtherPuns;) {\r
+\r
+    if (StartPun == 0xFFFFFFFF) {\r
+      //\r
+      // Remaining Device Path is NULL, scan all the possible Puns in the\r
+      // SCSI Channel.\r
+      //\r
+      Status = ScsiPassThru->GetNextDevice (ScsiPassThru, &Pun, &Lun);\r
+      if (EFI_ERROR (Status)) {\r
+        //\r
+        // no legal Pun and Lun found any more\r
+        //\r
+        break;\r
+      }\r
+    } else {\r
+      //\r
+      // Remaining Device Path is not NULL, only scan the specified Pun.\r
+      //\r
+      Pun           = StartPun;\r
+      Lun           = StartLun;\r
+      ScanOtherPuns = FALSE;\r
+    }\r
+    \r
+    //\r
+    // Avoid creating handle for the host adapter.\r
+    //\r
+    if (Pun == ScsiPassThru->Mode->AdapterId) {\r
+      continue;\r
+    }\r
+    \r
+    //\r
+    // Scan for the scsi device, if it attaches to the scsi bus,\r
+    // then create handle and install scsi i/o protocol.\r
+    //\r
+    Status = ScsiScanCreateDevice (This, Controller, Pun, Lun, ScsiPassThru, ParentDevicePath);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SCSIBusDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
+  IN  EFI_HANDLE                      Controller,\r
+  IN  UINTN                           NumberOfChildren,\r
+  IN  EFI_HANDLE                      *ChildHandleBuffer\r
+  )\r
+/*++\r
+  \r
+  Routine Description:\r
+  \r
+  Arguments:\r
+  \r
+  Returns:\r
+  \r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+// TODO:    Controller - add argument and description to function comment\r
+// TODO:    NumberOfChildren - add argument and description to function comment\r
+// TODO:    ChildHandleBuffer - add argument and description to function comment\r
+// TODO:    EFI_SUCCESS - add return value to function comment\r
+// TODO:    EFI_DEVICE_ERROR - add return value to function comment\r
+// TODO:    EFI_SUCCESS - add return value to function comment\r
+{\r
+  EFI_STATUS                  Status;\r
+  BOOLEAN                     AllChildrenStopped;\r
+  UINTN                       Index;\r
+  EFI_SCSI_IO_PROTOCOL        *ScsiIo;\r
+  SCSI_IO_DEV                 *ScsiIoDevice;\r
+  EFI_SCSI_PASS_THRU_PROTOCOL *ScsiPassThru;\r
+\r
+  if (NumberOfChildren == 0) {\r
+    //\r
+    // Close the bus driver\r
+    //\r
+    gBS->CloseProtocol (\r
+          Controller,\r
+          &gEfiScsiPassThruProtocolGuid,\r
+          This->DriverBindingHandle,\r
+          Controller\r
+          );\r
+    gBS->CloseProtocol (\r
+          Controller,\r
+          &gEfiDevicePathProtocolGuid,\r
+          This->DriverBindingHandle,\r
+          Controller\r
+          );\r
+\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  AllChildrenStopped = TRUE;\r
+\r
+  for (Index = 0; Index < NumberOfChildren; Index++) {\r
+\r
+    Status = gBS->OpenProtocol (\r
+                    ChildHandleBuffer[Index],\r
+                    &gEfiScsiIoProtocolGuid,\r
+                    (VOID **) &ScsiIo,\r
+                    This->DriverBindingHandle,\r
+                    Controller,\r
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      AllChildrenStopped = FALSE;\r
+      continue;\r
+    }\r
+\r
+    ScsiIoDevice = SCSI_IO_DEV_FROM_THIS (ScsiIo);\r
+    //\r
+    // Close the child handle\r
+    //\r
+    Status = gBS->CloseProtocol (\r
+                    Controller,\r
+                    &gEfiScsiPassThruProtocolGuid,\r
+                    This->DriverBindingHandle,\r
+                    ChildHandleBuffer[Index]\r
+                    );\r
+\r
+    Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                    ChildHandleBuffer[Index],\r
+                    &gEfiDevicePathProtocolGuid,\r
+                    ScsiIoDevice->DevicePath,\r
+                    &gEfiScsiIoProtocolGuid,\r
+                    &ScsiIoDevice->ScsiIo,\r
+                    NULL\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      AllChildrenStopped = FALSE;\r
+      gBS->OpenProtocol (\r
+            Controller,\r
+            &gEfiScsiPassThruProtocolGuid,\r
+            (VOID **) &ScsiPassThru,\r
+            This->DriverBindingHandle,\r
+            ChildHandleBuffer[Index],\r
+            EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+            );\r
+    } else {\r
+      gBS->FreePool (ScsiIoDevice);\r
+    }\r
+  }\r
+\r
+  if (!AllChildrenStopped) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ScsiGetDeviceType (\r
+  IN  EFI_SCSI_IO_PROTOCOL     *This,\r
+  OUT UINT8                    *DeviceType\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieves the device type information of the SCSI Controller.\r
+    \r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    DeviceType            - A pointer to the device type information\r
+                            retrieved from the SCSI Controller. \r
+\r
+  Returns:\r
+    EFI_SUCCESS           - Retrieves the device type information successfully.\r
+    EFI_INVALID_PARAMETER - The DeviceType is NULL.\r
+--*/\r
+{\r
+  SCSI_IO_DEV *ScsiIoDevice;\r
+\r
+  if (DeviceType == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  ScsiIoDevice  = SCSI_IO_DEV_FROM_THIS (This);\r
+  *DeviceType   = ScsiIoDevice->ScsiDeviceType;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+ScsiGetDeviceLocation (\r
+  IN  EFI_SCSI_IO_PROTOCOL    *This,\r
+  OUT UINT32                  *Target,\r
+  OUT UINT64                  *Lun\r
+  )\r
+/*++\r
+  Routine Description:\r
+    Retrieves the device location in the SCSI channel.\r
+    \r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    Target                - A pointer to the Target ID of a SCSI device \r
+                            on the SCSI channel. \r
+    Lun                   - A pointer to the LUN of the SCSI device on \r
+                            the SCSI channel.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - Retrieves the device location successfully.\r
+    EFI_INVALID_PARAMETER - The Target or Lun is NULL.\r
+--*/\r
+{\r
+  SCSI_IO_DEV *ScsiIoDevice;\r
+\r
+  if (Target == NULL || Lun == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  ScsiIoDevice  = SCSI_IO_DEV_FROM_THIS (This);\r
+\r
+  *Target       = ScsiIoDevice->Pun;\r
+  *Lun          = ScsiIoDevice->Lun;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ScsiResetBus (\r
+  IN  EFI_SCSI_IO_PROTOCOL     *This\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Resets the SCSI Bus that the SCSI Controller is attached to.\r
+    \r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The SCSI bus is reset successfully.\r
+    EFI_DEVICE_ERROR      - Errors encountered when resetting the SCSI bus.\r
+    EFI_UNSUPPORTED       - The bus reset operation is not supported by the\r
+                            SCSI Host Controller.\r
+    EFI_TIMEOUT           - A timeout occurred while attempting to reset \r
+                            the SCSI bus.\r
+--*/\r
+{\r
+  SCSI_IO_DEV *ScsiIoDevice;\r
+\r
+  ScsiIoDevice = SCSI_IO_DEV_FROM_THIS (This);\r
+\r
+  return ScsiIoDevice->ScsiPassThru->ResetChannel (ScsiIoDevice->ScsiPassThru);\r
+\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ScsiResetDevice (\r
+  IN  EFI_SCSI_IO_PROTOCOL     *This\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Resets the SCSI Controller that the device handle specifies.\r
+    \r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    \r
+\r
+  Returns:\r
+    EFI_SUCCESS           - Reset the SCSI controller successfully.\r
+    EFI_DEVICE_ERROR      - Errors are encountered when resetting the\r
+                            SCSI Controller.\r
+    EFI_UNSUPPORTED       - The SCSI bus does not support a device \r
+                            reset operation.\r
+    EFI_TIMEOUT           - A timeout occurred while attempting to \r
+                            reset the SCSI Controller.\r
+--*/\r
+{\r
+  SCSI_IO_DEV *ScsiIoDevice;\r
+\r
+  ScsiIoDevice = SCSI_IO_DEV_FROM_THIS (This);\r
+\r
+  return ScsiIoDevice->ScsiPassThru->ResetTarget (\r
+                                      ScsiIoDevice->ScsiPassThru,\r
+                                      ScsiIoDevice->Pun,\r
+                                      ScsiIoDevice->Lun\r
+                                      );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ScsiExecuteSCSICommand (\r
+  IN  EFI_SCSI_IO_PROTOCOL                         *This,\r
+  IN OUT  EFI_SCSI_IO_SCSI_REQUEST_PACKET          *Packet,\r
+  IN EFI_EVENT                                     Event  OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Sends a SCSI Request Packet to the SCSI Controller for execution.\r
+    \r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    Packet                - The SCSI request packet to send to the SCSI \r
+                            Controller specified by the device handle.\r
+    Event                 - If the SCSI bus where the SCSI device is attached\r
+                            does not support non-blocking I/O, then Event is \r
+                            ignored, and blocking I/O is performed.  \r
+                            If Event is NULL, then blocking I/O is performed.\r
+                            If Event is not NULL and non-blocking I/O is \r
+                            supported, then non-blocking I/O is performed,\r
+                            and Event will be signaled when the SCSI Request\r
+                            Packet completes.\r
+  Returns:\r
+    EFI_SUCCESS           - The SCSI Request Packet was sent by the host \r
+                            successfully, and TransferLength bytes were \r
+                            transferred to/from DataBuffer.See \r
+                            HostAdapterStatus, TargetStatus, \r
+                            SenseDataLength, and SenseData in that order\r
+                            for additional status information.\r
+    EFI_WARN_BUFFER_TOO_SMALL - The SCSI Request Packet was executed, \r
+                            but the entire DataBuffer could not be transferred.\r
+                            The actual number of bytes transferred is returned\r
+                            in TransferLength. See HostAdapterStatus, \r
+                            TargetStatus, SenseDataLength, and SenseData in \r
+                            that order for additional status information.\r
+    EFI_NOT_READY         - The SCSI Request Packet could not be sent because \r
+                            there are too many SCSI Command Packets already \r
+                            queued.The caller may retry again later.\r
+    EFI_DEVICE_ERROR      - A device error occurred while attempting to send \r
+                            the SCSI Request Packet. See HostAdapterStatus, \r
+                            TargetStatus, SenseDataLength, and SenseData in \r
+                            that order for additional status information.\r
+    EFI_INVALID_PARAMETER - The contents of CommandPacket are invalid.  \r
+                            The SCSI Request Packet was not sent, so no \r
+                            additional status information is available.\r
+    EFI_UNSUPPORTED       - The command described by the SCSI Request Packet\r
+                            is not supported by the SCSI initiator(i.e., SCSI \r
+                            Host Controller). The SCSI Request Packet was not\r
+                            sent, so no additional status information is \r
+                            available.\r
+    EFI_TIMEOUT           - A timeout occurred while waiting for the SCSI \r
+                            Request Packet to execute. See HostAdapterStatus,\r
+                            TargetStatus, SenseDataLength, and SenseData in \r
+                            that order for additional status information.\r
+--*/\r
+{\r
+  SCSI_IO_DEV                             *ScsiIoDevice;\r
+  EFI_STATUS                              Status;\r
+\r
+  EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET  *RequestPacket;\r
+\r
+  if (Packet == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  ScsiIoDevice  = SCSI_IO_DEV_FROM_THIS (This);\r
+\r
+  RequestPacket = (EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *) Packet;\r
+\r
+  Status = ScsiIoDevice->ScsiPassThru->PassThru (\r
+                                        ScsiIoDevice->ScsiPassThru,\r
+                                        ScsiIoDevice->Pun,\r
+                                        ScsiIoDevice->Lun,\r
+                                        RequestPacket,\r
+                                        Event\r
+                                        );\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+ScsiScanCreateDevice (\r
+  EFI_DRIVER_BINDING_PROTOCOL   *This,\r
+  EFI_HANDLE                    Controller,\r
+  UINT32                        Pun,\r
+  UINT64                        Lun,\r
+  EFI_SCSI_PASS_THRU_PROTOCOL   *ScsiPassThru,\r
+  EFI_DEVICE_PATH_PROTOCOL      *ParentDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This              - TODO: add argument description\r
+  Controller        - TODO: add argument description\r
+  Pun               - TODO: add argument description\r
+  Lun               - TODO: add argument description\r
+  ScsiPassThru      - TODO: add argument description\r
+  ParentDevicePath  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - TODO: Add description for return value\r
+  EFI_OUT_OF_RESOURCES - TODO: Add description for return value\r
+  EFI_SUCCESS - TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                Status;\r
+  SCSI_IO_DEV               *ScsiIoDevice;\r
+  EFI_DEVICE_PATH_PROTOCOL  *ScsiDevicePath;\r
+\r
+  Status = gBS->AllocatePool (\r
+                  EfiBootServicesData,\r
+                  sizeof (SCSI_IO_DEV),\r
+                  (VOID **) &ScsiIoDevice\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  ZeroMem (ScsiIoDevice, sizeof (SCSI_IO_DEV));\r
+\r
+  ScsiIoDevice->Signature                 = SCSI_IO_DEV_SIGNATURE;\r
+  ScsiIoDevice->ScsiPassThru              = ScsiPassThru;\r
+  ScsiIoDevice->Pun                       = Pun;\r
+  ScsiIoDevice->Lun                       = Lun;\r
+\r
+  ScsiIoDevice->ScsiIo.GetDeviceType      = ScsiGetDeviceType;\r
+  ScsiIoDevice->ScsiIo.GetDeviceLocation  = ScsiGetDeviceLocation;\r
+  ScsiIoDevice->ScsiIo.ResetBus           = ScsiResetBus;\r
+  ScsiIoDevice->ScsiIo.ResetDevice        = ScsiResetDevice;\r
+  ScsiIoDevice->ScsiIo.ExecuteSCSICommand = ScsiExecuteSCSICommand;\r
+\r
+  if (!DiscoverScsiDevice (ScsiIoDevice)) {\r
+    gBS->FreePool (ScsiIoDevice);\r
+    return EFI_SUCCESS;\r
+  }\r
+  \r
+  //\r
+  // Set Device Path\r
+  //\r
+  Status = ScsiIoDevice->ScsiPassThru->BuildDevicePath (\r
+                                        ScsiIoDevice->ScsiPassThru,\r
+                                        ScsiIoDevice->Pun,\r
+                                        ScsiIoDevice->Lun,\r
+                                        &ScsiDevicePath\r
+                                        );\r
+  if (Status == EFI_OUT_OF_RESOURCES) {\r
+    gBS->FreePool (ScsiIoDevice);\r
+    return Status;\r
+  }\r
+\r
+  ScsiIoDevice->DevicePath = AppendDevicePathNode (\r
+                              ParentDevicePath,\r
+                              ScsiDevicePath\r
+                              );\r
+  //\r
+  // The memory space for ScsiDevicePath is allocated in\r
+  // ScsiPassThru->BuildDevicePath() function; It is no longer used\r
+  // after EfiAppendDevicePathNode,so free the memory it occupies.\r
+  //\r
+  gBS->FreePool (ScsiDevicePath);\r
+\r
+  if (ScsiIoDevice->DevicePath == NULL) {\r
+    gBS->FreePool (ScsiIoDevice);\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &ScsiIoDevice->Handle,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  ScsiIoDevice->DevicePath,\r
+                  &gEfiScsiIoProtocolGuid,\r
+                  &ScsiIoDevice->ScsiIo,\r
+                  NULL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    gBS->FreePool (ScsiIoDevice);\r
+  } else {\r
+    gBS->OpenProtocol (\r
+          Controller,\r
+          &gEfiScsiPassThruProtocolGuid,\r
+          (VOID **) &ScsiPassThru,\r
+          This->DriverBindingHandle,\r
+          ScsiIoDevice->Handle,\r
+          EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+          );\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+BOOLEAN\r
+DiscoverScsiDevice (\r
+  SCSI_IO_DEV   *ScsiIoDevice\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ScsiIoDevice  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_SCSI_INQUIRY_DATA InquiryData;\r
+  UINT32                InquiryDataLength;\r
+  EFI_SCSI_SENSE_DATA   SenseData;\r
+  UINT8                 SenseDataLength;\r
+  UINT8                 HostAdapterStatus;\r
+  UINT8                 TargetStatus;\r
+\r
+  HostAdapterStatus = 0;\r
+  TargetStatus      = 0;\r
+  //\r
+  // Using Inquiry command to scan for the device\r
+  //\r
+  InquiryDataLength = sizeof (EFI_SCSI_INQUIRY_DATA);\r
+  SenseDataLength   = sizeof (EFI_SCSI_SENSE_DATA);\r
+\r
+  Status = SubmitInquiryCommand (\r
+            &ScsiIoDevice->ScsiIo,\r
+            EfiScsiStallSeconds (1),\r
+            (VOID *) &SenseData,\r
+            &SenseDataLength,\r
+            &HostAdapterStatus,\r
+            &TargetStatus,\r
+            (VOID *) &InquiryData,\r
+            &InquiryDataLength,\r
+            FALSE\r
+            );\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    //    ParseSenseData (&SenseData,SenseDataLength);\r
+    //\r
+    return FALSE;\r
+  }\r
+  //\r
+  // Retrieved inquiry data successfully\r
+  //\r
+  if ((InquiryData.Peripheral_Qualifier != 0) &&\r
+      (InquiryData.Peripheral_Qualifier != 3)) {\r
+    return FALSE;\r
+  }\r
+\r
+  if (InquiryData.Peripheral_Qualifier == 3) {\r
+    if (InquiryData.Peripheral_Type != 0x1f) {\r
+      return FALSE;\r
+    }\r
+  }\r
+\r
+  if ((0x1e >= InquiryData.Peripheral_Type) && (InquiryData.Peripheral_Type >= 0xa)) {\r
+    return FALSE;\r
+  }\r
+  \r
+  //\r
+  // valid device type and peripheral qualifier combination.\r
+  //\r
+  ScsiIoDevice->ScsiDeviceType  = InquiryData.Peripheral_Type;\r
+  ScsiIoDevice->RemovableDevice = InquiryData.RMB;\r
+  if (InquiryData.Version == 0) {\r
+    ScsiIoDevice->ScsiVersion = 0;\r
+  } else {\r
+    //\r
+    // ANSI-approved version\r
+    //\r
+    ScsiIoDevice->ScsiVersion = (UINT8) (InquiryData.Version & 0x03);\r
+  }\r
+\r
+  return TRUE;\r
+}\r
diff --git a/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.h b/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.h
new file mode 100644 (file)
index 0000000..594953e
--- /dev/null
@@ -0,0 +1,312 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which 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
+\r
+Module Name:\r
+\r
+    ScsiBus.h\r
+\r
+Abstract:\r
+\r
+    Header file for SCSI Bus Driver.\r
+\r
+Revision History\r
+++*/\r
+\r
+// TODO: fix comment to end with --*/\r
+#ifndef _SCSI_BUS_H\r
+#define _SCSI_BUS_H\r
+\r
+\r
+#include <IndustryStandard/scsi.h>\r
+//\r
+// 1000 * 1000 * 10\r
+//\r
+#define ONE_SECOND_TIMER      10000000  \r
+\r
+#define SCSI_IO_DEV_SIGNATURE EFI_SIGNATURE_32 ('s', 'c', 'i', 'o')\r
+\r
+typedef struct {\r
+  UINT32                      Signature;\r
+\r
+  EFI_HANDLE                  Handle;\r
+  EFI_SCSI_IO_PROTOCOL        ScsiIo;\r
+  EFI_DEVICE_PATH_PROTOCOL    *DevicePath;\r
+  EFI_SCSI_PASS_THRU_PROTOCOL *ScsiPassThru;\r
+\r
+  UINT32                      Pun;\r
+  UINT64                      Lun;\r
+  UINT8                       ScsiDeviceType;\r
+  UINT8                       ScsiVersion;\r
+  BOOLEAN                     RemovableDevice;\r
+} SCSI_IO_DEV;\r
+\r
+#define SCSI_IO_DEV_FROM_THIS(a)  CR (a, SCSI_IO_DEV, ScsiIo, SCSI_IO_DEV_SIGNATURE)\r
+\r
+//\r
+// Global Variables\r
+//\r
+extern EFI_DRIVER_BINDING_PROTOCOL  gScsiBusDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL  gScsiBusComponentName;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SCSIBusDriverBindingSupported (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN EFI_HANDLE                   Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SCSIBusDriverBindingStart (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN EFI_HANDLE                   Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SCSIBusDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
+  IN  EFI_HANDLE                      Controller,\r
+  IN  UINTN                           NumberOfChildren,\r
+  IN  EFI_HANDLE                      *ChildHandleBuffer\r
+  );\r
+\r
+//\r
+// EFI Component Name Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+ScsiBusComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ScsiBusComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                           *Language,\r
+  OUT CHAR16                                          **ControllerName\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ScsiGetDeviceType (\r
+  IN  EFI_SCSI_IO_PROTOCOL     *This,\r
+  OUT UINT8                    *DeviceType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This        - TODO: add argument description\r
+  DeviceType  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ScsiResetBus (\r
+  IN  EFI_SCSI_IO_PROTOCOL     *This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ScsiResetDevice (\r
+  IN  EFI_SCSI_IO_PROTOCOL     *This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ScsiExecuteSCSICommand (\r
+  IN  EFI_SCSI_IO_PROTOCOL                 *This,\r
+  IN OUT  EFI_SCSI_IO_SCSI_REQUEST_PACKET  *CommandPacket,\r
+  IN  EFI_EVENT                            Event\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This          - TODO: add argument description\r
+  CommandPacket - TODO: add argument description\r
+  Event         - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+ScsiScanCreateDevice (\r
+  EFI_DRIVER_BINDING_PROTOCOL   *This,\r
+  EFI_HANDLE                    Controller,\r
+  UINT32                        Pun,\r
+  UINT64                        Lun,\r
+  EFI_SCSI_PASS_THRU_PROTOCOL   *ScsiPassThru,\r
+  EFI_DEVICE_PATH_PROTOCOL      *ParentDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This              - TODO: add argument description\r
+  Controller        - TODO: add argument description\r
+  Pun               - TODO: add argument description\r
+  Lun               - TODO: add argument description\r
+  ScsiPassThru      - TODO: add argument description\r
+  ParentDevicePath  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN\r
+DiscoverScsiDevice (\r
+  SCSI_IO_DEV   *ScsiIoDevice\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ScsiIoDevice  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+GetLunList (\r
+  EFI_SCSI_PASS_THRU_PROTOCOL *ScsiPassThru,\r
+  UINT32                      Target,\r
+  UINT64                      **LunArray,\r
+  UINTN                       *NumberOfLuns\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ScsiPassThru  - TODO: add argument description\r
+  Target        - TODO: add argument description\r
+  LunArray      - TODO: add argument description\r
+  NumberOfLuns  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+ScsiBusSubmitReportLunCommand (\r
+  EFI_SCSI_PASS_THRU_PROTOCOL   *ScsiPassThru,\r
+  UINT32                        Target,\r
+  UINTN                         AllocationLength,\r
+  VOID                          *Buffer,\r
+  EFI_SCSI_SENSE_DATA           *SenseData,\r
+  UINT8                         *SenseDataLength,\r
+  UINT8                         *HostAdapterStatus,\r
+  UINT8                         *TargetStatus\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ScsiPassThru      - TODO: add argument description\r
+  Target            - TODO: add argument description\r
+  AllocationLength  - TODO: add argument description\r
+  Buffer            - TODO: add argument description\r
+  SenseData         - TODO: add argument description\r
+  SenseDataLength   - TODO: add argument description\r
+  HostAdapterStatus - TODO: add argument description\r
+  TargetStatus      - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+#endif\r
diff --git a/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.inf b/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.inf
new file mode 100644 (file)
index 0000000..47ead53
--- /dev/null
@@ -0,0 +1,105 @@
+#/** @file\r
+# Component description file for Scsi Bus module.\r
+#\r
+# SCSI bus driver. This driver scans all SCSI devices and export SCSI IO protocol\r
+# Copyright (c) 2006 - 2007, Intel Corporation\r
+#\r
+#  All rights reserved. This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\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
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = ScsiBus\r
+  FILE_GUID                      = 0167CCC4-D0F7-4f21-A3EF-9E64B7CDCE8B\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00010010\r
+\r
+  ENTRY_POINT                    = InitializeScsiBus\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+#  DRIVER_BINDING                =  gSCSIBusDriverBinding                        \r
+#  COMPONENT_NAME                =  gScsiBusComponentName                        \r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+  ComponentName.c\r
+  ScsiBus.c\r
+  ScsiBus.h\r
+\r
+\r
+################################################################################\r
+#\r
+# Includes Section - list of Include locations that are required for\r
+#                    this module.\r
+#\r
+################################################################################\r
+\r
+[Includes]\r
+  $(WORKSPACE)/MdePkg/Include/Library\r
+  $(WORKSPACE)/MdeModulePkg/Include/Library\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+#                              this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+  MdeModulePkg/MdeModulePkg.dec\r
+  MdePkg/MdePkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+#                         this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+  DevicePathLib\r
+  UefiBootServicesTableLib\r
+  ScsiLib\r
+  BaseMemoryLib\r
+  UefiLib\r
+  UefiDriverEntryPoint\r
+  DebugLib\r
+\r
+\r
+################################################################################\r
+#\r
+# Protocol C Name Section - list of Protocol and Protocol Notify C Names\r
+#                           that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Protocols]\r
+  gEfiScsiIoProtocolGuid                        # PROTOCOL BY_START\r
+  gEfiDevicePathProtocolGuid                    # PROTOCOL TO_START\r
+  gEfiScsiPassThruProtocolGuid                  # PROTOCOL TO_START\r
+\r
diff --git a/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.msa b/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.msa
new file mode 100644 (file)
index 0000000..4dba827
--- /dev/null
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+  <MsaHeader>\r
+    <ModuleName>ScsiBus</ModuleName>\r
+    <ModuleType>DXE_DRIVER</ModuleType>\r
+    <GuidValue>0167CCC4-D0F7-4f21-A3EF-9E64B7CDCE8B</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Component description file for Scsi Bus module.</Abstract>\r
+    <Description>SCSI bus driver. This driver scans all SCSI devices and export SCSI IO protocol</Description>\r
+    <Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\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.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>ScsiBus</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverModelLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>EdkScsiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DevicePathLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>ScsiBus.h</Filename>\r
+    <Filename>ScsiBus.c</Filename>\r
+    <Filename>ComponentName.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="TO_START">\r
+      <ProtocolCName>gEfiScsiPassThruProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="TO_START">\r
+      <ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="BY_START">\r
+      <ProtocolCName>gEfiScsiIoProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00010010</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <DriverBinding>gSCSIBusDriverBinding</DriverBinding>\r
+      <ComponentName>gScsiBusComponentName</ComponentName>\r
+    </Extern>\r
+  </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
index c28dc82..baf274a 100644 (file)
   DxeServicesTableLib|${WORKSPACE}/MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf\r
   FvbServiceLib|${WORKSPACE}/MdeModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.inf\r
   ReportStatusCodeLib|${WORKSPACE}/IntelFrameworkPkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf\r
-\r
+  ScsiLib|$(WORKSPACE)/MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
+  \r
 [LibraryClasses.common.DXE_RUNTIME_DRIVER]\r
   HobLib|${WORKSPACE}/MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
   MemoryAllocationLib|${WORKSPACE}/MdePkg/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.inf\r
   DxeServicesTableLib|${WORKSPACE}/MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf\r
   FvbServiceLib|${WORKSPACE}/MdeModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.inf\r
   ReportStatusCodeLib|${WORKSPACE}/IntelFrameworkPkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf\r
-\r
+  ScsiLib|$(WORKSPACE)/MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
+  \r
 [LibraryClasses.common.DXE_SAL_DRIVER]\r
   HobLib|${WORKSPACE}/MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
   MemoryAllocationLib|${WORKSPACE}/MdePkg/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.inf\r
   UefiRuntimeServicesTableLib|${WORKSPACE}/MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf\r
   FvbServiceLib|${WORKSPACE}/MdeModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.inf\r
   ReportStatusCodeLib|${WORKSPACE}/IntelFrameworkPkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf\r
-\r
+  ScsiLib|$(WORKSPACE)/MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
 \r
 [LibraryClasses.common.DXE_SMM_DRIVER]\r
   HobLib|${WORKSPACE}/MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
   UefiRuntimeServicesTableLib|${WORKSPACE}/MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf\r
   FvbServiceLib|${WORKSPACE}/MdeModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.inf\r
   ReportStatusCodeLib|${WORKSPACE}/IntelFrameworkPkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf\r
-\r
+  ScsiLib|$(WORKSPACE)/MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
 \r
 [LibraryClasses.common.UEFI_DRIVER]\r
   HobLib|${WORKSPACE}/MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
   UefiRuntimeServicesTableLib|${WORKSPACE}/MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf\r
   FvbServiceLib|${WORKSPACE}/MdeModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.inf\r
   ReportStatusCodeLib|${WORKSPACE}/IntelFrameworkPkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf\r
-\r
+  ScsiLib|$(WORKSPACE)/MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
 \r
 [LibraryClasses.common.UEFI_APPLICATION]\r
   HobLib|${WORKSPACE}/MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
   DebugLib|${WORKSPACE}/MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf\r
   FvbServiceLib|${WORKSPACE}/MdeModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.inf\r
   ReportStatusCodeLib|${WORKSPACE}/IntelFrameworkPkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf\r
-\r
+  ScsiLib|$(WORKSPACE)/MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
 \r
 [LibraryClasses.IA32.BASE]\r
   TimerLib|${WORKSPACE}/MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf\r
   ${WORKSPACE}/MdeModulePkg/Bus/Pci/AtapiPassThru/Dxe/AtapiPassThru.inf\r
   ${WORKSPACE}/MdeModulePkg/Universal/WatchDogTimerDxe/WatchDogTimer.inf\r
   ${WORKSPACE}/MdeModulePkg/Universal/VariablePei/Variable.inf\r
+  ${WORKSPACE}/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.inf
\ No newline at end of file
index 68b3165..c9e2600 100644 (file)
   DebugLib|$(WORKSPACE)/MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf\r
   DxeServicesTableLib|$(WORKSPACE)/MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf\r
   PrintLib|$(WORKSPACE)/MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
-  EdkScsiLib|$(WORKSPACE)/MdeModulePkg/Library/EdkScsiLib/EdkScsiLib.inf\r
+  ScsiLib|$(WORKSPACE)/MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
   UefiDecompressLib|$(WORKSPACE)/MdeModulePkg/Library/DxeCoreUefiDecompressLibFromHob/DxeCoreUefiDecompressLibFromHob.inf\r
   FrameworkHiiLib|$(WORKSPACE)/IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.inf\r
   UefiBootServicesTableLib|$(WORKSPACE)/MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf\r
   UefiRuntimeLib|$(WORKSPACE)/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf\r
   TianoDecompressLib|$(WORKSPACE)/MdeModulePkg/Library/DxeCoreTianoDecompressLibFromHob/DxeCoreTianoDecompressLibFromHob.inf\r
   EdkUsbLib|$(WORKSPACE)/MdeModulePkg/Library/EdkUsbLib/EdkUsbLib.inf\r
-  EdkScsiLib|$(WORKSPACE)/MdeModulePkg/Library/EdkScsiLib/EdkScsiLib.inf\r
+  ScsiLib|$(WORKSPACE)/MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
   UefiDriverModelLib|$(WORKSPACE)/MdePkg/Library/UefiDriverModelLib/UefiDriverModelLib.inf\r
   FvbServiceLib|${WORKSPACE}/MdeModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.inf\r
 \r
   BaseMemoryLib|$(WORKSPACE)/MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf\r
   TianoDecompressLib|$(WORKSPACE)/MdeModulePkg/Library/DxeCoreTianoDecompressLibFromHob/DxeCoreTianoDecompressLibFromHob.inf\r
   EdkUsbLib|$(WORKSPACE)/MdeModulePkg/Library/EdkUsbLib/EdkUsbLib.inf\r
-  EdkScsiLib|$(WORKSPACE)/MdeModulePkg/Library/EdkScsiLib/EdkScsiLib.inf\r
+  ScsiLib|$(WORKSPACE)/MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
   UefiDriverModelLib|$(WORKSPACE)/MdePkg/Library/UefiDriverModelLib/UefiDriverModelLib.inf\r
   FvbServiceLib|${WORKSPACE}/MdeModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.inf\r
 \r
   BaseMemoryLib|$(WORKSPACE)/MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf\r
   TianoDecompressLib|$(WORKSPACE)/MdeModulePkg/Library/DxeCoreTianoDecompressLibFromHob/DxeCoreTianoDecompressLibFromHob.inf\r
   EdkUsbLib|$(WORKSPACE)/MdeModulePkg/Library/EdkUsbLib/EdkUsbLib.inf\r
-  EdkScsiLib|$(WORKSPACE)/MdeModulePkg/Library/EdkScsiLib/EdkScsiLib.inf\r
+  ScsiLib|$(WORKSPACE)/MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
   UefiDriverModelLib|$(WORKSPACE)/MdePkg/Library/UefiDriverModelLib/UefiDriverModelLib.inf\r
   FvbServiceLib|${WORKSPACE}/MdeModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.inf\r
 \r
   DebugLib|$(WORKSPACE)/MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf\r
   DxeServicesTableLib|$(WORKSPACE)/MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf\r
   PrintLib|$(WORKSPACE)/MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
-  EdkScsiLib|$(WORKSPACE)/MdeModulePkg/Library/EdkScsiLib/EdkScsiLib.inf\r
+  ScsiLib|$(WORKSPACE)/MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
   UefiDecompressLib|$(WORKSPACE)/MdeModulePkg/Library/DxeCoreUefiDecompressLibFromHob/DxeCoreUefiDecompressLibFromHob.inf\r
   FrameworkHiiLib|$(WORKSPACE)/IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.inf\r
   UefiApplicationEntryPoint|$(WORKSPACE)/MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf\r
   $(WORKSPACE)/IntelFrameworkModulePkg/Bus/Pci/IdeBus/Dxe/IdeBus.inf\r
   $(WORKSPACE)/IntelFrameworkModulePkg/Universal/DataHub/DataHub/Dxe/DataHub.inf\r
   $(WORKSPACE)/IntelFrameworkModulePkg/Universal/DataHub/DataHubStdErr/Dxe/DataHubStdErr.inf\r
+  ${WORKSPACE}/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.inf
\ No newline at end of file