Skip to content
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

Use newtype enum definitions from uefi-raw in uefi's pxe module #1551

Merged
merged 2 commits into from
Feb 18, 2025
Merged
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
64 changes: 11 additions & 53 deletions uefi/src/proto/network/pxe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ use crate::proto::unsafe_protocol;
use crate::util::ptr_write_unaligned_and_add;
use bitflags::bitflags;
use ptr_meta::Pointee;
use uefi_raw::protocol::network::pxe::PxeBaseCodeTftpOpcode;

use crate::{CStr8, Char8, Result, Status, StatusExt};

use super::{IpAddress, MacAddress};

pub use uefi_raw::protocol::network::pxe::{
PxeBaseCodeIpFilterFlags as IpFilters, PxeBaseCodeUdpOpFlags as UdpOpFlags,
PxeBaseCodeBootType as BootstrapType, PxeBaseCodeIpFilterFlags as IpFilters,
PxeBaseCodeUdpOpFlags as UdpOpFlags,
};

/// PXE Base Code protocol
Expand All @@ -41,7 +43,7 @@ pub struct BaseCode {
) -> Status,
mtftp: unsafe extern "efiapi" fn(
this: &Self,
operation: TftpOpcode,
operation: PxeBaseCodeTftpOpcode,
buffer: *mut c_void,
overwrite: bool,
buffer_size: &mut u64,
Expand Down Expand Up @@ -156,7 +158,7 @@ impl BaseCode {
let status = unsafe {
(self.mtftp)(
self,
TftpOpcode::TftpGetFileSize,
PxeBaseCodeTftpOpcode::TFTP_GET_FILE_SIZE,
null_mut(),
false,
&mut buffer_size,
Expand Down Expand Up @@ -187,7 +189,7 @@ impl BaseCode {
let status = unsafe {
(self.mtftp)(
self,
TftpOpcode::TftpReadFile,
PxeBaseCodeTftpOpcode::TFTP_READ_FILE,
buffer_ptr,
false,
&mut buffer_size,
Expand Down Expand Up @@ -215,7 +217,7 @@ impl BaseCode {
unsafe {
(self.mtftp)(
self,
TftpOpcode::TftpWriteFile,
PxeBaseCodeTftpOpcode::TFTP_WRITE_FILE,
buffer_ptr,
overwrite,
&mut buffer_size,
Expand Down Expand Up @@ -243,7 +245,7 @@ impl BaseCode {
let status = unsafe {
(self.mtftp)(
self,
TftpOpcode::TftpReadDirectory,
PxeBaseCodeTftpOpcode::TFTP_READ_DIRECTORY,
buffer_ptr,
false,
&mut buffer_size,
Expand Down Expand Up @@ -316,7 +318,7 @@ impl BaseCode {
let status = unsafe {
(self.mtftp)(
self,
TftpOpcode::MtftpGetFileSize,
PxeBaseCodeTftpOpcode::MTFTP_GET_FILE_SIZE,
null_mut(),
false,
&mut buffer_size,
Expand Down Expand Up @@ -348,7 +350,7 @@ impl BaseCode {
let status = unsafe {
(self.mtftp)(
self,
TftpOpcode::MtftpReadFile,
PxeBaseCodeTftpOpcode::MTFTP_READ_FILE,
buffer_ptr,
false,
&mut buffer_size,
Expand Down Expand Up @@ -376,7 +378,7 @@ impl BaseCode {
let status = unsafe {
(self.mtftp)(
self,
TftpOpcode::MtftpReadDirectory,
PxeBaseCodeTftpOpcode::MTFTP_READ_DIRECTORY,
buffer_ptr,
false,
&mut buffer_size,
Expand Down Expand Up @@ -616,38 +618,6 @@ impl BaseCode {
}
}

/// A type of bootstrap to perform in [`BaseCode::discover`].
///
/// Corresponds to the `EFI_PXE_BASE_CODE_BOOT_` constants in the C API.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[repr(u16)]
#[allow(missing_docs)]
pub enum BootstrapType {
Bootstrap = 0,
MsWinntRis = 1,
IntelLcm = 2,
DosUndi = 3,
NecEsmpro = 4,
IbmWsoD = 5,
IbmLccm = 6,
CaUnicenterTng = 7,
HpOpenview = 8,
Altiris9 = 9,
Altiris10 = 10,
Altiris11 = 11,
// NOT_USED_12 = 12,
RedhatInstall = 13,
RedhatBoot = 14,
Rembo = 15,
Beoboot = 16,
//
// Values 17 through 32767 are reserved.
// Values 32768 through 65279 are for vendor use.
// Values 65280 through 65534 are reserved.
//
PxeTest = 65535,
}

opaque_type! {
/// Opaque type that should be used to represent a pointer to a [`DiscoverInfo`] in
/// foreign function interfaces. This type produces a thin pointer, unlike
Expand Down Expand Up @@ -798,18 +768,6 @@ impl Server {
}
}

/// Corresponds to the `EFI_PXE_BASE_CODE_TFTP_OPCODE` type in the C API.
#[repr(C)]
enum TftpOpcode {
TftpGetFileSize = 1,
TftpReadFile,
TftpWriteFile,
TftpReadDirectory,
MtftpGetFileSize,
MtftpReadFile,
MtftpReadDirectory,
}

/// MTFTP connection parameters
///
/// Corresponds to the `EFI_PXE_BASE_CODE_MTFTP_INFO` type in the C API.
Expand Down