Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ae01a75

Browse files
Merge pull request #1638 from JarlEvanson/redefine-usb
uefi-raw: Redefine UsbPortStatus and UsbTransferStatus
2 parents c458cb6 + 15cf732 commit ae01a75

File tree

2 files changed

+54
-7
lines changed

2 files changed

+54
-7
lines changed

‎uefi-raw/src/protocol/usb/host_controller.rs

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,38 @@ pub struct TransactionTranslator {
5555

5656
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
5757
#[repr(C)]
58-
pub struct PortStatus {
59-
pub port_status: u16,
60-
pub port_change_status: u16,
58+
pub struct UsbPortStatus {
59+
pub port_status: PortStatus,
60+
pub port_change_status: PortChangeStatus,
61+
}
62+
63+
bitflags! {
64+
#[repr(transparent)]
65+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
66+
pub struct PortStatus: u16 {
67+
const CONNECTION = 0x0001;
68+
const ENABLE = 0x0002;
69+
const SUSPEND = 0x0004;
70+
const OVER_CURRENT = 0x0008;
71+
const RESET = 0x0010;
72+
const POWER = 0x0100;
73+
const LOW_SPEED = 0x0200;
74+
const HIGH_SPEED = 0x0400;
75+
const SUPER_SPEED = 0x0800;
76+
const OWNER = 0x2000;
77+
}
78+
}
79+
80+
bitflags! {
81+
#[repr(transparent)]
82+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
83+
pub struct PortChangeStatus: u16 {
84+
const CONNECTION = 0x0001;
85+
const ENABLE = 0x0002;
86+
const SUSPEND = 0x0004;
87+
const OVER_CURRENT = 0x0008;
88+
const RESET = 0x0010;
89+
}
6190
}
6291

6392
newtype_enum! {
@@ -170,7 +199,7 @@ pub struct Usb2HostControllerProtocol {
170199
pub get_root_hub_port_status: unsafe extern "efiapi" fn(
171200
this: *mut Self,
172201
port_number: u8,
173-
port_status: *mut PortStatus,
202+
port_status: *mut UsbPortStatus,
174203
) -> Status,
175204
pub set_root_hub_port_feature: unsafe extern "efiapi" fn(
176205
this: *mut Self,

‎uefi-raw/src/protocol/usb/mod.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
use core::ffi;
44

5+
use bitflags::bitflags;
6+
57
use crate::Status;
68

79
pub mod host_controller;
@@ -25,9 +27,25 @@ pub struct DeviceRequest {
2527
pub length: u16,
2628
}
2729

28-
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
29-
#[repr(transparent)]
30-
pub struct UsbTransferStatus(pub u32);
30+
bitflags! {
31+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
32+
#[repr(transparent)]
33+
pub struct UsbTransferStatus: u32 {
34+
const NOT_EXECUTE = 0x0001;
35+
const STALL = 0x0002;
36+
const BUFFER = 0x0004;
37+
const BABBLE = 0x0008;
38+
const NAK = 0x0010;
39+
const CRC = 0x0020;
40+
const TIMEOUT = 0x0040;
41+
const BIT_STUFF = 0x0080;
42+
const SYSTEM = 0x0100;
43+
}
44+
}
45+
46+
impl UsbTransferStatus {
47+
pub const SUCCESS: Self = Self::empty();
48+
}
3149

3250
pub type AsyncUsbTransferCallback = unsafe extern "efiapi" fn(
3351
data: *mut ffi::c_void,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /