Skip to content

uefi-raw: Add EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL bindings #1591

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 26, 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 @@ -9,6 +9,7 @@
address types.
- Added `DiskInfoProtocol`.
- Added `ExtScsiPassThruProtocol`.
- Added `NvmExpressPassThruProtocol`.


# uefi-raw - 0.10.0 (2025-02-07)
Expand Down
1 change: 1 addition & 0 deletions uefi-raw/src/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub mod media;
pub mod memory_protection;
pub mod misc;
pub mod network;
pub mod nvme;
pub mod rng;
pub mod scsi;
pub mod shell_params;
Expand Down
82 changes: 82 additions & 0 deletions uefi-raw/src/protocol/nvme.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// SPDX-License-Identifier: MIT OR Apache-2.0

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

#[derive(Debug)]
#[repr(C)]
pub struct NvmExpressPassThruMode {
pub attributes: u32,
pub io_align: u32,
pub nvme_version: u32,
}

/// This structure maps to the NVM Express specification Submission Queue Entry
#[derive(Debug)]
#[repr(C)]
pub struct NvmExpressCommand {
pub cdw0: u32,
pub flags: u8,
pub nsid: u32,
pub cdw2: u32,
pub cdw3: u32,
pub cdw10: u32,
pub cdw11: u32,
pub cdw12: u32,
pub cdw13: u32,
pub cdw14: u32,
pub cdw15: u32,
}

/// This structure maps to the NVM Express specification Completion Queue Entry
#[derive(Debug)]
#[repr(C)]
pub struct NvmExpressCompletion {
pub dw0: u32,
pub dw1: u32,
pub dw2: u32,
pub dw3: u32,
}

#[derive(Debug)]
#[repr(C)]
pub struct NvmExpressPassThruCommandPacket {
pub command_timeout: u64,
pub transfer_buffer: *mut c_void,
pub transfer_length: u32,
pub meta_data_buffer: *mut c_void,
pub meta_data_length: u32,
pub queue_type: u8,
pub nvme_cmd: *const NvmExpressCommand,
pub nvme_completion: *mut NvmExpressCompletion,
}

#[derive(Debug)]
#[repr(C)]
pub struct NvmExpressPassThruProtocol {
pub mode: *const NvmExpressPassThruMode,
pub pass_thru: unsafe extern "efiapi" fn(
this: *const Self,
namespace_id: u32,
packet: *mut NvmExpressPassThruCommandPacket,
event: *mut c_void,
) -> Status,
pub get_next_namespace:
unsafe extern "efiapi" fn(this: *const Self, namespace_id: *mut u32) -> Status,
pub build_device_path: unsafe extern "efiapi" fn(
this: *const Self,
namespace_id: u32,
device_path: *mut *mut DevicePathProtocol,
) -> Status,
pub get_namespace: unsafe extern "efiapi" fn(
this: *const Self,
device_path: *const DevicePathProtocol,
namespace_id: *mut u32,
) -> Status,
}

impl NvmExpressPassThruProtocol {
pub const GUID: Guid = guid!("52c78312-8edc-4233-98f2-1a1aa5e388a5");
}
Loading