Skip to content

Commit 53b822e

Browse files
authored
Merge pull request #1551 from nicholasbishop/bishop-use-raw-pxe-enums
Use newtype enum definitions from uefi-raw in uefi's pxe module
2 parents 470a1ed + 82131cc commit 53b822e

File tree

1 file changed

+11
-53
lines changed

1 file changed

+11
-53
lines changed

uefi/src/proto/network/pxe.rs

Lines changed: 11 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ use crate::proto::unsafe_protocol;
1313
use crate::util::ptr_write_unaligned_and_add;
1414
use bitflags::bitflags;
1515
use ptr_meta::Pointee;
16+
use uefi_raw::protocol::network::pxe::PxeBaseCodeTftpOpcode;
1617

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

1920
use super::{IpAddress, MacAddress};
2021

2122
pub use uefi_raw::protocol::network::pxe::{
22-
PxeBaseCodeIpFilterFlags as IpFilters, PxeBaseCodeUdpOpFlags as UdpOpFlags,
23+
PxeBaseCodeBootType as BootstrapType, PxeBaseCodeIpFilterFlags as IpFilters,
24+
PxeBaseCodeUdpOpFlags as UdpOpFlags,
2325
};
2426

2527
/// PXE Base Code protocol
@@ -41,7 +43,7 @@ pub struct BaseCode {
4143
) -> Status,
4244
mtftp: unsafe extern "efiapi" fn(
4345
this: &Self,
44-
operation: TftpOpcode,
46+
operation: PxeBaseCodeTftpOpcode,
4547
buffer: *mut c_void,
4648
overwrite: bool,
4749
buffer_size: &mut u64,
@@ -156,7 +158,7 @@ impl BaseCode {
156158
let status = unsafe {
157159
(self.mtftp)(
158160
self,
159-
TftpOpcode::TftpGetFileSize,
161+
PxeBaseCodeTftpOpcode::TFTP_GET_FILE_SIZE,
160162
null_mut(),
161163
false,
162164
&mut buffer_size,
@@ -187,7 +189,7 @@ impl BaseCode {
187189
let status = unsafe {
188190
(self.mtftp)(
189191
self,
190-
TftpOpcode::TftpReadFile,
192+
PxeBaseCodeTftpOpcode::TFTP_READ_FILE,
191193
buffer_ptr,
192194
false,
193195
&mut buffer_size,
@@ -215,7 +217,7 @@ impl BaseCode {
215217
unsafe {
216218
(self.mtftp)(
217219
self,
218-
TftpOpcode::TftpWriteFile,
220+
PxeBaseCodeTftpOpcode::TFTP_WRITE_FILE,
219221
buffer_ptr,
220222
overwrite,
221223
&mut buffer_size,
@@ -243,7 +245,7 @@ impl BaseCode {
243245
let status = unsafe {
244246
(self.mtftp)(
245247
self,
246-
TftpOpcode::TftpReadDirectory,
248+
PxeBaseCodeTftpOpcode::TFTP_READ_DIRECTORY,
247249
buffer_ptr,
248250
false,
249251
&mut buffer_size,
@@ -316,7 +318,7 @@ impl BaseCode {
316318
let status = unsafe {
317319
(self.mtftp)(
318320
self,
319-
TftpOpcode::MtftpGetFileSize,
321+
PxeBaseCodeTftpOpcode::MTFTP_GET_FILE_SIZE,
320322
null_mut(),
321323
false,
322324
&mut buffer_size,
@@ -348,7 +350,7 @@ impl BaseCode {
348350
let status = unsafe {
349351
(self.mtftp)(
350352
self,
351-
TftpOpcode::MtftpReadFile,
353+
PxeBaseCodeTftpOpcode::MTFTP_READ_FILE,
352354
buffer_ptr,
353355
false,
354356
&mut buffer_size,
@@ -376,7 +378,7 @@ impl BaseCode {
376378
let status = unsafe {
377379
(self.mtftp)(
378380
self,
379-
TftpOpcode::MtftpReadDirectory,
381+
PxeBaseCodeTftpOpcode::MTFTP_READ_DIRECTORY,
380382
buffer_ptr,
381383
false,
382384
&mut buffer_size,
@@ -616,38 +618,6 @@ impl BaseCode {
616618
}
617619
}
618620

619-
/// A type of bootstrap to perform in [`BaseCode::discover`].
620-
///
621-
/// Corresponds to the `EFI_PXE_BASE_CODE_BOOT_` constants in the C API.
622-
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
623-
#[repr(u16)]
624-
#[allow(missing_docs)]
625-
pub enum BootstrapType {
626-
Bootstrap = 0,
627-
MsWinntRis = 1,
628-
IntelLcm = 2,
629-
DosUndi = 3,
630-
NecEsmpro = 4,
631-
IbmWsoD = 5,
632-
IbmLccm = 6,
633-
CaUnicenterTng = 7,
634-
HpOpenview = 8,
635-
Altiris9 = 9,
636-
Altiris10 = 10,
637-
Altiris11 = 11,
638-
// NOT_USED_12 = 12,
639-
RedhatInstall = 13,
640-
RedhatBoot = 14,
641-
Rembo = 15,
642-
Beoboot = 16,
643-
//
644-
// Values 17 through 32767 are reserved.
645-
// Values 32768 through 65279 are for vendor use.
646-
// Values 65280 through 65534 are reserved.
647-
//
648-
PxeTest = 65535,
649-
}
650-
651621
opaque_type! {
652622
/// Opaque type that should be used to represent a pointer to a [`DiscoverInfo`] in
653623
/// foreign function interfaces. This type produces a thin pointer, unlike
@@ -798,18 +768,6 @@ impl Server {
798768
}
799769
}
800770

801-
/// Corresponds to the `EFI_PXE_BASE_CODE_TFTP_OPCODE` type in the C API.
802-
#[repr(C)]
803-
enum TftpOpcode {
804-
TftpGetFileSize = 1,
805-
TftpReadFile,
806-
TftpWriteFile,
807-
TftpReadDirectory,
808-
MtftpGetFileSize,
809-
MtftpReadFile,
810-
MtftpReadDirectory,
811-
}
812-
813771
/// MTFTP connection parameters
814772
///
815773
/// Corresponds to the `EFI_PXE_BASE_CODE_MTFTP_INFO` type in the C API.

0 commit comments

Comments
 (0)