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

Commit 2620330

Browse files
committed
Support SCSI storage
HyperV only support SCSI storage. To run on HyperV, SCSI storage must be supported Tracked-On: OAM-92157 Signed-off-by: JianFeng,Zhou <jianfeng.zhou@intel.com>
1 parent e4aafe0 commit 2620330

6 files changed

Lines changed: 255 additions & 20 deletions

File tree

include/storage.h

100755100644
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ enum storage_type {
4343
STORAGE_SATA,
4444
STORAGE_NVME,
4545
STORAGE_VIRTUAL,
46+
STORAGE_ISCSI,
4647
#ifdef USB_STORAGE
4748
STORAGE_USB,
4849
#endif
@@ -94,4 +95,6 @@ EFI_STATUS set_logical_unit(UINT64 user_lun, UINT64 factory_lun);
9495
void print_progress(EFI_LBA done, EFI_LBA total, uint32_t sec, uint32_t *prev_sec, uint32_t *prev);
9596
void set_exclude_device(EFI_HANDLE device);
9697

98+
SCSI_DEVICE_PATH* get_scsi_device_path(EFI_DEVICE_PATH *p);
99+
97100
#endif /* _STORAGE_H_ */

libfastboot/fastboot_oem.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,10 @@ static void cmd_oem_set_storage(INTN argc, CHAR8 **argv)
338338
types[total_types++] = STORAGE_NVME;
339339
continue;
340340
}
341+
if (!strcmp(argv[i], (CHAR8 *)"iscsi")) {
342+
types[total_types++] = STORAGE_ISCSI;
343+
continue;
344+
}
341345
if (!strcmp(argv[i], (CHAR8 *)"sdcard")) {
342346
types[total_types++] = STORAGE_SDCARD;
343347
continue;

libkernelflinger/Android.mk

100755100644
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ LOCAL_SRC_FILES := \
123123
qsort.c \
124124
timer.c \
125125
nvme.c \
126+
iscsi.c \
126127
virtual_media.c \
127128
general_block.c \
128129
aes_gcm.c \

libkernelflinger/android.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,17 +1063,27 @@ static EFI_STATUS setup_command_line(
10631063
PCI_DEVICE_PATH *boot_device = get_boot_device();
10641064
if (boot_device) {
10651065
CHAR16 *diskbus = NULL;
1066+
enum storage_type storage_type;
10661067
#ifdef AUTO_DISKBUS
10671068
diskbus = PoolPrint(L"%02x.%x", boot_device->Device, boot_device->Function);
10681069
#else
10691070
diskbus = PoolPrint(L"%a", (CHAR8 *)PREDEF_DISK_BUS);
10701071
#endif
10711072
StrToLower(diskbus);
1072-
ret = prepend_command_line(&cmdline16,
1073-
(aosp_header->header_version < 2)
1074-
? L"androidboot.diskbus=%s"
1075-
: L"androidboot.boot_devices=pci0000:00/0000:00:%s",
1076-
diskbus);
1073+
1074+
get_boot_device_type(&storage_type);
1075+
if(aosp_header->header_version < 2)
1076+
ret = prepend_command_line(&cmdline16,
1077+
L"androidboot.diskbus=%s",
1078+
diskbus);
1079+
else
1080+
if(storage_type == STORAGE_ISCSI)
1081+
ret = prepend_command_line(&cmdline16,
1082+
L"androidboot.boot_devices=scsi_disk/0:0:0:0");
1083+
else
1084+
ret = prepend_command_line(&cmdline16,
1085+
L"androidboot.boot_devices=pci0000:00/0000:00:%s",
1086+
diskbus);
10771087
FreePool(diskbus);
10781088
if (EFI_ERROR(ret))
10791089
goto out;

libkernelflinger/iscsi.c

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
* Copyright (c) 2020, Intel Corporation
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions
7+
* are met:
8+
*
9+
* * Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
* * Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer
13+
* in the documentation and/or other materials provided with the
14+
* distribution.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
19+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
27+
* OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*
29+
* This file defines bootlogic data structures, try to keep it without
30+
* any external definitions in order to ease export of it.
31+
*/
32+
33+
#include <lib.h>
34+
#include "storage.h"
35+
36+
#include "protocol/NvmExpressHci.h"
37+
#include "protocol/DevicePath.h"
38+
#include "protocol/NvmExpressPassthru.h"
39+
40+
#define ATTR_UNUSED __attribute__((unused))
41+
42+
#define MSG_SCSI_DP 0x02
43+
44+
#include "pci.h"
45+
46+
#if 0
47+
static void *get_iscsi_device_path(EFI_DEVICE_PATH *p)
48+
{
49+
for (; !IsDevicePathEndType(p); p = NextDevicePathNode(p)) {
50+
if (DevicePathType(p) == MESSAGING_DEVICE_PATH
51+
&& DevicePathSubType(p) == MSG_SCSI_DP)
52+
return (void *)p;
53+
}
54+
55+
return NULL;
56+
}
57+
#endif
58+
59+
SCSI_DEVICE_PATH* get_scsi_device_path(EFI_DEVICE_PATH *p)
60+
{
61+
if (!p)
62+
return NULL;
63+
64+
while (!IsDevicePathEndType(p)) {
65+
if (DevicePathType(p) == MESSAGING_DEVICE_PATH
66+
&& DevicePathSubType(p) == MSG_SCSI_DP)
67+
return (SCSI_DEVICE_PATH *)p;
68+
p = NextDevicePathNode(p);
69+
}
70+
return NULL;
71+
}
72+
73+
static EFI_STATUS iscsi_erase_blocks(
74+
EFI_HANDLE handle ATTR_UNUSED,
75+
EFI_BLOCK_IO *bio ATTR_UNUSED,
76+
EFI_LBA start ATTR_UNUSED,
77+
EFI_LBA end ATTR_UNUSED
78+
)
79+
{
80+
return EFI_UNSUPPORTED;
81+
}
82+
83+
static EFI_STATUS iscsi_check_logical_unit(ATTR_UNUSED EFI_DEVICE_PATH *p, ATTR_UNUSED logical_unit_t log_unit)
84+
{
85+
return log_unit == LOGICAL_UNIT_USER ? EFI_SUCCESS : EFI_UNSUPPORTED;
86+
}
87+
88+
static BOOLEAN is_iscsi(EFI_DEVICE_PATH *p)
89+
{
90+
return get_scsi_device_path(p) != NULL;
91+
}
92+
93+
struct storage STORAGE(STORAGE_ISCSI) = {
94+
.erase_blocks = iscsi_erase_blocks,
95+
.check_logical_unit = iscsi_check_logical_unit,
96+
.probe = is_iscsi,
97+
.name = L"ISCSI"
98+
};
99+
100+

0 commit comments

Comments
 (0)