-
Notifications
You must be signed in to change notification settings - Fork 1
Add DevicePath functions/utilities #10
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
Conversation
src/util/device_path.rs
Outdated
|
||
for i in 0..filename_len as isize{ | ||
unsafe { | ||
*file_name_ptr.offset(i) = *filename.as_ptr().offset(i) as u16; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be setting file_name_ptr
from filename_ptr
, not filename.as_ptr()
.
Also maybe some better names?
src/protocol/device_path.rs
Outdated
impl DevicePathFromTextProtocol { | ||
pub fn text_to_device_path_node(&self, path: &str) -> Result<&DevicePathProtocol, Status> { | ||
str_to_utf16_ptr(path) | ||
.map(|utf16_str| unsafe { &*((self.text_to_device_path_node)(utf16_str)) }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is utf16_str
leaked?
src/protocol/device_path.rs
Outdated
|
||
pub fn text_to_device_path(&self, path: &str) -> Result<&DevicePathProtocol, Status> { | ||
str_to_utf16_ptr(path) | ||
.map(|utf16_str| unsafe { &*((self.text_to_device_path)(utf16_str)) }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise.
src/util/device_path.rs
Outdated
.boot_services() | ||
.locate_protocol::<DevicePathUtilitiesProtocol>(0 as *const CVoid) | ||
.and_then(|utilities| { | ||
utilities.create_device_node(4, 4, node_size_bytes as u16) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is 4
worth a couple of constants?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, probably. Realistically the best thing to do is to flesh out all the DevicePath types and subtypes from the spec, I was just a little hesitant to do that since we're not using many of them.
Updated with requested changes. |
src/util/device_path.rs
Outdated
|
||
for i in 0..filename_len as isize{ | ||
unsafe { | ||
*node_filename_ptr.offset(i) = *filename_ptr.offset(i) as u16; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is as u16
redundant here?
|
||
#[allow(non_camel_case_types)] | ||
#[repr(u8)] | ||
pub enum MessagingSubTypes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please either sort, or leave a comment explaining the sort order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorted by value, since the spec order doesn't seem to have any rhyme or reason.
src/protocol/device_path.rs
Outdated
IPv6 = 0xD, | ||
UART = 0xE, | ||
USBClass = 0xF, | ||
// The EFI specification calls this type "1394", but that won't work as an enum variant for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, yep. Thanks.
Add enums for all device path types as laid out in the UEFI spec. Also, add implementations of Into<u8> for each.
Instead of using *const u16s and Console.write_raw() in DevicePathToTextProtocol, use &str and write() instead.
Add a function to allocate and create a DevicePathProtocol struct containing a filename.
CVoid is needed for passing to some functions.
Primary changes:
DevicePathUtilities
for manipulatingDevicePathProtocol
structsDevicePathFromText
for parsing strings intoDevicePathProtocol
structscreate_file_device_node
for creatingDevicePathProtocol
structs for files