Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Commit

Permalink
Support SCSI storage
Browse files Browse the repository at this point in the history
HyperV only support SCSI storage.
To run on HyperV, SCSI storage must be supported

Tracked-On: OAM-92157
Signed-off-by: JianFeng,Zhou <[email protected]>
  • Loading branch information
zhouji3x committed Aug 17, 2020
1 parent e4aafe0 commit 2620330
Show file tree
Hide file tree
Showing 6 changed files with 255 additions and 20 deletions.
3 changes: 3 additions & 0 deletions include/storage.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ enum storage_type {
STORAGE_SATA,
STORAGE_NVME,
STORAGE_VIRTUAL,
STORAGE_ISCSI,
#ifdef USB_STORAGE
STORAGE_USB,
#endif
Expand Down Expand Up @@ -94,4 +95,6 @@ EFI_STATUS set_logical_unit(UINT64 user_lun, UINT64 factory_lun);
void print_progress(EFI_LBA done, EFI_LBA total, uint32_t sec, uint32_t *prev_sec, uint32_t *prev);
void set_exclude_device(EFI_HANDLE device);

SCSI_DEVICE_PATH* get_scsi_device_path(EFI_DEVICE_PATH *p);

#endif /* _STORAGE_H_ */
4 changes: 4 additions & 0 deletions libfastboot/fastboot_oem.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ static void cmd_oem_set_storage(INTN argc, CHAR8 **argv)
types[total_types++] = STORAGE_NVME;
continue;
}
if (!strcmp(argv[i], (CHAR8 *)"iscsi")) {
types[total_types++] = STORAGE_ISCSI;
continue;
}
if (!strcmp(argv[i], (CHAR8 *)"sdcard")) {
types[total_types++] = STORAGE_SDCARD;
continue;
Expand Down
1 change: 1 addition & 0 deletions libkernelflinger/Android.mk
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ LOCAL_SRC_FILES := \
qsort.c \
timer.c \
nvme.c \
iscsi.c \
virtual_media.c \
general_block.c \
aes_gcm.c \
Expand Down
20 changes: 15 additions & 5 deletions libkernelflinger/android.c
Original file line number Diff line number Diff line change
Expand Up @@ -1063,17 +1063,27 @@ static EFI_STATUS setup_command_line(
PCI_DEVICE_PATH *boot_device = get_boot_device();
if (boot_device) {
CHAR16 *diskbus = NULL;
enum storage_type storage_type;
#ifdef AUTO_DISKBUS
diskbus = PoolPrint(L"%02x.%x", boot_device->Device, boot_device->Function);
#else
diskbus = PoolPrint(L"%a", (CHAR8 *)PREDEF_DISK_BUS);
#endif
StrToLower(diskbus);
ret = prepend_command_line(&cmdline16,
(aosp_header->header_version < 2)
? L"androidboot.diskbus=%s"
: L"androidboot.boot_devices=pci0000:00/0000:00:%s",
diskbus);

get_boot_device_type(&storage_type);
if(aosp_header->header_version < 2)
ret = prepend_command_line(&cmdline16,
L"androidboot.diskbus=%s",
diskbus);
else
if(storage_type == STORAGE_ISCSI)
ret = prepend_command_line(&cmdline16,
L"androidboot.boot_devices=scsi_disk/0:0:0:0");
else
ret = prepend_command_line(&cmdline16,
L"androidboot.boot_devices=pci0000:00/0000:00:%s",
diskbus);
FreePool(diskbus);
if (EFI_ERROR(ret))
goto out;
Expand Down
100 changes: 100 additions & 0 deletions libkernelflinger/iscsi.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* Copyright (c) 2020, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file defines bootlogic data structures, try to keep it without
* any external definitions in order to ease export of it.
*/

#include <lib.h>
#include "storage.h"

#include "protocol/NvmExpressHci.h"
#include "protocol/DevicePath.h"
#include "protocol/NvmExpressPassthru.h"

#define ATTR_UNUSED __attribute__((unused))

#define MSG_SCSI_DP 0x02

#include "pci.h"

#if 0
static void *get_iscsi_device_path(EFI_DEVICE_PATH *p)
{
for (; !IsDevicePathEndType(p); p = NextDevicePathNode(p)) {
if (DevicePathType(p) == MESSAGING_DEVICE_PATH
&& DevicePathSubType(p) == MSG_SCSI_DP)
return (void *)p;
}

return NULL;
}
#endif

SCSI_DEVICE_PATH* get_scsi_device_path(EFI_DEVICE_PATH *p)
{
if (!p)
return NULL;

while (!IsDevicePathEndType(p)) {
if (DevicePathType(p) == MESSAGING_DEVICE_PATH
&& DevicePathSubType(p) == MSG_SCSI_DP)
return (SCSI_DEVICE_PATH *)p;
p = NextDevicePathNode(p);
}
return NULL;
}

static EFI_STATUS iscsi_erase_blocks(
EFI_HANDLE handle ATTR_UNUSED,
EFI_BLOCK_IO *bio ATTR_UNUSED,
EFI_LBA start ATTR_UNUSED,
EFI_LBA end ATTR_UNUSED
)
{
return EFI_UNSUPPORTED;
}

static EFI_STATUS iscsi_check_logical_unit(ATTR_UNUSED EFI_DEVICE_PATH *p, ATTR_UNUSED logical_unit_t log_unit)
{
return log_unit == LOGICAL_UNIT_USER ? EFI_SUCCESS : EFI_UNSUPPORTED;
}

static BOOLEAN is_iscsi(EFI_DEVICE_PATH *p)
{
return get_scsi_device_path(p) != NULL;
}

struct storage STORAGE(STORAGE_ISCSI) = {
.erase_blocks = iscsi_erase_blocks,
.check_logical_unit = iscsi_check_logical_unit,
.probe = is_iscsi,
.name = L"ISCSI"
};


Loading

0 comments on commit 2620330

Please sign in to comment.