|
| 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