Skip to content

uefi-raw: Add EXT_SCSI_PASS_THRU protocol binding #1581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions uefi-raw/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Added `protocol::network::pxe` module.
- Added conversions between `MacAddress` and the `[u8; 6]` type that's more commonly used to represent MAC addresses.
- Added `DiskInfoProtocol`.
- Added `ExtScsiPassThruProtocol`.


# uefi-raw - 0.10.0 (2025-02-07)
Expand Down
47 changes: 47 additions & 0 deletions uefi-raw/src/protocol/scsi.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// SPDX-License-Identifier: MIT OR Apache-2.0

use super::device_path::DevicePathProtocol;
use crate::{guid, Event, Guid, Status};
use core::ffi::c_void;

pub const SCSI_TARGET_MAX_BYTES: usize = 0x10;

newtype_enum! {
/// Corresponds to the `EFI_SCSI_IO_TYPE_*` defines.
#[derive(Default)]
Expand Down Expand Up @@ -111,3 +114,47 @@ pub struct ScsiIoProtocol {
impl ScsiIoProtocol {
pub const GUID: Guid = guid!("932f47e6-2362-4002-803e-3cd54b138f85");
}

#[derive(Clone, Debug)]
#[repr(C)]
pub struct ExtScsiPassThruMode {
pub adapter_id: u32,
pub attributes: u32,
pub io_align: u32,
}

#[derive(Debug)]
#[repr(C)]
pub struct ExtScsiPassThruProtocol {
pub passthru_mode: *const ExtScsiPassThruMode,
pub pass_thru: unsafe extern "efiapi" fn(
this: *const Self,
target: *const u8,
lun: u64,
packet: *mut ScsiIoScsiRequestPacket,
event: Event,
) -> Status,
pub get_next_target_lun:
unsafe extern "efiapi" fn(this: *const Self, target: *mut *mut u8, lun: *mut u64) -> Status,
pub build_device_path: unsafe extern "efiapi" fn(
this: *const Self,
target: *const u8,
lun: u64,
device_path: *mut *const DevicePathProtocol,
) -> Status,
pub get_target_lun: unsafe extern "efiapi" fn(
this: *const Self,
device_path: *const DevicePathProtocol,
target: *mut *const u8,
lun: *mut u64,
) -> Status,
pub reset_channel: unsafe extern "efiapi" fn(this: *mut Self) -> Status,
pub reset_target_lun:
unsafe extern "efiapi" fn(this: *mut Self, target: *const u8, lun: u64) -> Status,
pub get_next_target:
unsafe extern "efiapi" fn(this: *const Self, target: *mut *mut u8) -> Status,
}

impl ExtScsiPassThruProtocol {
pub const GUID: Guid = guid!("143b7632-b81b-4cb7-abd3-b625a5b9bffe");
}