From 1703c37fbb6de709686389f455f1795173226c3f Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Thu, 30 May 2024 11:26:40 -0600 Subject: [PATCH] Update redox_uefi_std Signed-off-by: Tim Crawford --- Cargo.lock | 21 +++++++++------------ Cargo.toml | 2 +- src/display.rs | 4 ++-- src/fde.rs | 23 ++++++++++------------- src/image/bmp.rs | 2 ++ src/image/mod.rs | 4 +++- src/key.rs | 4 ++-- src/main.rs | 8 -------- src/rng.rs | 6 +++--- src/security.rs | 20 ++++++++++---------- src/serial.rs | 4 ++-- src/ui.rs | 13 ++++++++----- 12 files changed, 52 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e79260c..036e592 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -42,9 +42,9 @@ checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" [[package]] name = "libc" -version = "0.2.154" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libm" @@ -152,24 +152,21 @@ dependencies = [ [[package]] name = "redox_uefi" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3dbb9124e850a6953efb6ea3957d84fc48930a6dfd844d963bc8516c16f24e5" +version = "0.1.12" +source = "git+https://gitlab.redox-os.org/redox-os/uefi.git#e2ab29c68a9d1093abb06435a4d0a593d23bfa25" [[package]] name = "redox_uefi_alloc" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4ac0164918610031fe226ba74125aa03239eb86516131b8ee1e85de31b7c445" +version = "0.1.12" +source = "git+https://gitlab.redox-os.org/redox-os/uefi.git#e2ab29c68a9d1093abb06435a4d0a593d23bfa25" dependencies = [ "redox_uefi", ] [[package]] name = "redox_uefi_std" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8e07da7709f8d1edbabf81657cd360886539c5c4a18fc047ed774bc1d6b466a" +version = "0.1.12" +source = "git+https://gitlab.redox-os.org/redox-os/uefi.git#e2ab29c68a9d1093abb06435a4d0a593d23bfa25" dependencies = [ "redox_uefi", "redox_uefi_alloc", @@ -204,7 +201,7 @@ dependencies = [ [[package]] name = "system76_ectool" version = "0.3.8" -source = "git+https://github.com/system76/ec.git#88c77aa1d322d2cca56038b396b31a96bc42fe59" +source = "git+https://github.com/system76/ec.git#fc3bad29a2a31555bccaaacb6af6d20b7bb1b7f6" dependencies = [ "downcast-rs", "redox_hwio", diff --git a/Cargo.toml b/Cargo.toml index d0088fe..b153543 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ orbfont = { version = "0.1.12", default-features = false, features = ["no-std"] plain = "0.2.3" redox_dmi = "0.1.6" redox_hwio = { version = "0.1.6", default-features = false } -redox_uefi_std = "0.1.11" +redox_uefi_std = { git = "https://gitlab.redox-os.org/redox-os/uefi.git" } spin = "0.9.4" [dependencies.system76_ectool] diff --git a/src/display.rs b/src/display.rs index a874dc7..b2866b1 100644 --- a/src/display.rs +++ b/src/display.rs @@ -1,8 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-only use core::cell::Cell; -use core::ops::Try; use orbclient::{Color, Mode, Renderer}; +use std::prelude::*; use std::proto::Protocol; use std::uefi::graphics::{GraphicsOutput, GraphicsBltOp, GraphicsBltPixel}; use std::uefi::guid::{Guid, GRAPHICS_OUTPUT_PROTOCOL_GUID}; @@ -53,7 +53,7 @@ impl Display { h as usize, 0 ); - status.branch().is_continue() + status.is_success() } } diff --git a/src/fde.rs b/src/fde.rs index 2c868e5..3989c47 100644 --- a/src/fde.rs +++ b/src/fde.rs @@ -1,12 +1,12 @@ // SPDX-License-Identifier: GPL-3.0-only use core::prelude::v1::derive; -use core::ops::FromResidual; use orbclient::{Color, Renderer}; use orbfont::Text; -use std::{char, cmp, ffi, mem, ptr, slice}; -use std::ops::Try; +use core::{char, cmp, mem, ptr, slice}; +use std::prelude::*; use std::proto::Protocol; +use std::ffi; use std::uefi::Event; use std::uefi::guid::Guid; use std::uefi::hii::{AnimationId, ImageId, StringId}; @@ -16,7 +16,7 @@ use std::uefi::hii::ifr::{ IfrOpCode, IfrOpHeader, IfrStatementHeader, IfrTypeValueEnum, IfrAction, IfrCheckbox, IfrNumeric, IfrOneOf, IfrOneOfOption, IfrOrderedList, IfrRef, IfrSubtitle }; -use std::uefi::status::{Error, Result, Status}; +use std::uefi::status::{Result, Status}; use std::uefi::text::TextInputKey; use crate::display::{Display, Output}; @@ -47,7 +47,7 @@ impl HiiStringProtocol { pub fn string(&self, PackageList: HiiHandle, StringId: StringId) -> Result { let mut data = vec![0u16; 4096]; let mut len = data.len(); - (self.GetString)( + Result::from((self.GetString)( self, b"en-US\0".as_ptr(), PackageList, @@ -55,7 +55,7 @@ impl HiiStringProtocol { data.as_mut_ptr(), &mut len, 0 - )?; + ))?; data.truncate(len); let mut string = String::new(); @@ -354,7 +354,7 @@ fn wait_for_events(form: &Form) -> Result { events.push(form.FormRefreshEvent); } - (uefi.BootServices.WaitForEvent)(events.len(), events.as_mut_ptr(), &mut index)?; + Result::from((uefi.BootServices.WaitForEvent)(events.len(), events.as_mut_ptr(), &mut index))?; if index == 0 { Ok(EventType::Keyboard) @@ -776,7 +776,7 @@ fn form_display_inner(form: &Form, user_input: &mut UserInput) -> Result<()> { let raw_key = match raw_key(false) { Ok(ok) => ok, Err(err) => match err { - Error::NotReady => break 'input, + Status::NOT_READY => break 'input, _ => return Err(err), } }; @@ -1030,10 +1030,7 @@ fn form_display_inner(form: &Form, user_input: &mut UserInput) -> Result<()> { } extern "win64" fn form_display(form: &Form, user_input: &mut UserInput) -> Status { - match form_display_inner(form, user_input) { - Ok(()) => Status::from_output(0), - Err(err) => Status::from_residual(err), - } + form_display_inner(form, user_input).into() } extern "win64" fn exit_display() { @@ -1053,7 +1050,7 @@ impl Fde { let current = unsafe { let mut interface = 0; - (uefi.BootServices.LocateProtocol)(&guid, 0, &mut interface)?; + Result::from((uefi.BootServices.LocateProtocol)(&guid, 0, &mut interface))?; &mut *(interface as *mut Fde) }; diff --git a/src/image/bmp.rs b/src/image/bmp.rs index ce02e35..1b68b7c 100644 --- a/src/image/bmp.rs +++ b/src/image/bmp.rs @@ -2,6 +2,8 @@ use super::Image; +use std::prelude::*; + pub fn parse(file_data: &[u8]) -> Result { use orbclient::Color; diff --git a/src/image/mod.rs b/src/image/mod.rs index d3f12ff..c79fc0d 100644 --- a/src/image/mod.rs +++ b/src/image/mod.rs @@ -2,7 +2,9 @@ use core::cell::Cell; use core::cmp; -use core::prelude::v1::derive; +use core::default::Default; + +use std::prelude::*; use orbclient::{Color, Mode, Renderer}; diff --git a/src/key.rs b/src/key.rs index 6494598..9368700 100644 --- a/src/key.rs +++ b/src/key.rs @@ -79,7 +79,7 @@ pub fn raw_key(wait: bool) -> Result { if wait { let mut index = 0; - (uefi.BootServices.WaitForEvent)(1, &uefi.ConsoleIn.WaitForKey, &mut index)?; + Result::from((uefi.BootServices.WaitForEvent)(1, &uefi.ConsoleIn.WaitForKey, &mut index))?; } let mut key = TextInputKey { @@ -87,7 +87,7 @@ pub fn raw_key(wait: bool) -> Result { UnicodeChar: 0 }; - (uefi.ConsoleIn.ReadKeyStroke)(uefi.ConsoleIn, &mut key)?; + Result::from((uefi.ConsoleIn.ReadKeyStroke)(uefi.ConsoleIn, &mut key))?; Ok(key) } diff --git a/src/main.rs b/src/main.rs index 03107e8..7ceeb98 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,21 +2,13 @@ #![no_std] #![no_main] -#![feature(core_intrinsics)] -#![feature(prelude_import)] -#![feature(try_trait_v2)] -#![feature(control_flow_enum)] #![allow(non_snake_case)] -#[macro_use] -extern crate bitflags; #[macro_use] extern crate memoffset; #[macro_use] extern crate uefi_std as std; -#[allow(unused_imports)] -#[prelude_import] use std::prelude::*; use core::ptr; diff --git a/src/rng.rs b/src/rng.rs index 775bec6..6d41b1e 100644 --- a/src/rng.rs +++ b/src/rng.rs @@ -1,6 +1,6 @@ +use core::ptr; use std::{ proto::Protocol, - ptr, }; use std::uefi::{ guid::Guid, @@ -13,12 +13,12 @@ pub struct Rng(pub &'static mut RngProtocol); impl Rng { pub fn read(&self, buf: &mut [u8]) -> Result<()> { - (self.0.GetRNG)( + Result::from((self.0.GetRNG)( self.0, ptr::null(), buf.len(), buf.as_mut_ptr(), - )?; + ))?; Ok(()) } } diff --git a/src/security.rs b/src/security.rs index 652d522..96c0014 100644 --- a/src/security.rs +++ b/src/security.rs @@ -1,17 +1,17 @@ +use core::cell::Cell; +use core::cmp; +use core::ptr; + use ectool::{AccessLpcDirect, Ec, SecurityState, Timeout}; use orbclient::{Color, Renderer}; -use std::{ - cell::Cell, - cmp, - proto::Protocol, - ptr, -}; +use std::prelude::*; +use std::proto::Protocol; use std::uefi::{ Handle, boot::InterfaceType, guid::Guid, reset::ResetType, - status::{Error, Result, Status}, + status::{Result, Status}, }; use crate::display::{Display, Output}; @@ -228,7 +228,7 @@ fn confirm(display: &mut Display) -> Result<()> { } } else { // Return error if cancel selected - return Err(Error::Aborted); + return Err(Status::ABORTED); } }, Key::Escape => { @@ -341,12 +341,12 @@ pub fn install() -> Result<()> { }); let protocol_ptr = Box::into_raw(protocol); let mut handle = Handle(0); - (uefi.BootServices.InstallProtocolInterface)( + Result::from((uefi.BootServices.InstallProtocolInterface)( &mut handle, &SYSTEM76_SECURITY_PROTOCOL_GUID, InterfaceType::Native, protocol_ptr as usize - )?; + ))?; Ok(()) } diff --git a/src/serial.rs b/src/serial.rs index a141094..7513310 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -4,7 +4,7 @@ use core::convert::TryInto; use core::prelude::v1::derive; use hwio::{Io, Pio, Mmio, ReadOnly}; -bitflags! { +bitflags::bitflags! { /// Interrupt enable flags struct IntEnFlags: u8 { const RECEIVED = 1; @@ -15,7 +15,7 @@ bitflags! { } } -bitflags! { +bitflags::bitflags! { /// Line status flags struct LineStsFlags: u8 { const INPUT_FULL = 1; diff --git a/src/ui.rs b/src/ui.rs index 77b13d1..d887f4f 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -1,7 +1,10 @@ +use core::ptr; + use orbclient::{Color, Renderer}; use orbfont::{Font, Text}; -use std::ptr; -use std::uefi::status::{Error, Result}; + +use std::prelude::*; +use std::uefi::status::{Result, Status}; use crate::display::Display; use crate::image::{self, Image}; @@ -39,7 +42,7 @@ impl Ui { Ok(ok) => ok, Err(err) => { println!("failed to parse font: {}", err); - return Err(Error::NotFound); + return Err(Status::NOT_FOUND); } }; FONT = Box::into_raw(Box::new(font)); @@ -53,7 +56,7 @@ impl Ui { Ok(ok) => ok, Err(err) => { println!("failed to parse checkbox checked: {}", err); - return Err(Error::NotFound); + return Err(Status::NOT_FOUND); } }; CHECKBOX_CHECKED = Box::into_raw(Box::new(image)); @@ -67,7 +70,7 @@ impl Ui { Ok(ok) => ok, Err(err) => { println!("failed to parse checkbox unchecked: {}", err); - return Err(Error::NotFound); + return Err(Status::NOT_FOUND); } }; CHECKBOX_UNCHECKED = Box::into_raw(Box::new(image));