diff --git a/Cargo.lock b/Cargo.lock index e79260c..87a8d92 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#695096ab997d7a207cad90d976d8907306b7eb98" [[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#695096ab997d7a207cad90d976d8907306b7eb98" 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#695096ab997d7a207cad90d976d8907306b7eb98" 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..49ef000 100644 --- a/src/display.rs +++ b/src/display.rs @@ -1,11 +1,11 @@ // 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}; +use std::uefi::guid::GRAPHICS_OUTPUT_PROTOCOL_GUID; pub struct Output(pub &'static mut GraphicsOutput); @@ -53,7 +53,7 @@ impl Display { h as usize, 0 ); - status.branch().is_continue() + status.is_success() } } diff --git a/src/dump_hii.rs b/src/dump_hii.rs index ce26f90..0de35f6 100644 --- a/src/dump_hii.rs +++ b/src/dump_hii.rs @@ -4,11 +4,11 @@ use hwio::{Io, Pio}; use std::{char, mem, ptr, str}; use std::ops::Try; use std::proto::Protocol; +use std::prelude::*; use std::uefi::hii::database::HiiHandle; use std::uefi::hii::ifr::{IfrOpCode, IfrOpHeader, IfrForm, IfrAction}; use std::uefi::hii::package::{HiiPackageHeader, HiiPackageKind, HiiPackageListHeader, HiiStringPackageHeader}; use std::uefi::hii::sibt::{SibtHeader, SibtKind, SibtEnd, SibtSkip2, SibtStringUcs2, SibtStringsUcs2}; -use std::uefi::status::{Error, Result}; use crate::hii; diff --git a/src/fde.rs b/src/fde.rs index 2c868e5..9e0e178 100644 --- a/src/fde.rs +++ b/src/fde.rs @@ -1,14 +1,11 @@ // 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::uefi::Event; -use std::uefi::guid::Guid; +use std::ffi; use std::uefi::hii::{AnimationId, ImageId, StringId}; use std::uefi::hii::database::HiiHandle; use std::uefi::hii::ifr::{ @@ -16,7 +13,6 @@ 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::text::TextInputKey; use crate::display::{Display, Output}; @@ -24,7 +20,7 @@ use crate::key::{raw_key, Key}; use crate::ui::Ui; // TODO: Move to uefi library { -pub const HII_STRING_PROTOCOL_GUID: Guid = Guid(0xfd96974, 0x23aa, 0x4cdc, [0xb9, 0xcb, 0x98, 0xd1, 0x77, 0x50, 0x32, 0x2a]); +pub const HII_STRING_PROTOCOL_GUID: Guid = guid!("0fd96974-23aa-4cdc-b9cb-98d17750322a"); #[repr(C)] pub struct HiiStringProtocol { @@ -47,7 +43,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 +51,7 @@ impl HiiStringProtocol { data.as_mut_ptr(), &mut len, 0 - )?; + ))?; data.truncate(len); let mut string = String::new(); @@ -354,7 +350,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 +772,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 +1026,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() { @@ -1047,13 +1040,13 @@ extern "win64" fn confirm_data_change() -> usize { impl Fde { pub fn install() -> Result<()> { - let guid = Guid(0x9bbe29e9, 0xfda1, 0x41ec, [0xad, 0x52, 0x45, 0x22, 0x13, 0x74, 0x2d, 0x2e]); + let guid = guid!("9bbe29e9-fda1-41ec-ad52-452213742d2e"); let uefi = unsafe { std::system_table_mut() }; 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/hii.rs b/src/hii.rs index 62e862c..bc4ef9e 100644 --- a/src/hii.rs +++ b/src/hii.rs @@ -1,8 +1,9 @@ // SPDX-License-Identifier: GPL-3.0-only use std::proto::Protocol; +use std::prelude::*; use std::uefi::hii::database::HiiDatabase; -use std::uefi::guid::{Guid, HII_DATABASE_GUID}; +use std::uefi::guid::HII_DATABASE_GUID; pub struct Database(pub &'static mut HiiDatabase); diff --git a/src/image/bmp.rs b/src/image/bmp.rs index ce02e35..844dedc 100644 --- a/src/image/bmp.rs +++ b/src/image/bmp.rs @@ -2,7 +2,9 @@ use super::Image; -pub fn parse(file_data: &[u8]) -> Result { +use std::prelude::*; + +pub fn parse(file_data: &[u8]) -> core::result::Result { use orbclient::Color; let get = |i: usize| -> u8 { diff --git a/src/image/mod.rs b/src/image/mod.rs index d3f12ff..40d8257 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}; @@ -51,7 +53,7 @@ impl Image { } /// Create a new image from a boxed slice of colors - pub fn from_data(width: u32, height: u32, data: Box<[Color]>) -> Result { + pub fn from_data(width: u32, height: u32, data: Box<[Color]>) -> core::result::Result { if (width * height) as usize != data.len() { return Err("not enough or too much data given compared to width and height".to_string()) } diff --git a/src/key.rs b/src/key.rs index 6494598..75be2d9 100644 --- a/src/key.rs +++ b/src/key.rs @@ -1,8 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only use core::char; -use core::prelude::v1::derive; -use std::uefi::status::Result; +use std::prelude::*; use std::uefi::text::TextInputKey; #[derive(Debug)] @@ -79,7 +78,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 +86,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..33f6a5a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,25 +2,16 @@ #![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; -use std::uefi::status::Status; #[macro_use] mod debug; diff --git a/src/rng.rs b/src/rng.rs index 775bec6..a5df5ec 100644 --- a/src/rng.rs +++ b/src/rng.rs @@ -1,11 +1,6 @@ -use std::{ - proto::Protocol, - ptr, -}; -use std::uefi::{ - guid::Guid, - status::{Result, Status}, -}; +use core::ptr; +use std::proto::Protocol; +use std::prelude::*; pub const RNG_PROTOCOL_GUID: Guid = Guid(0x3152bca5, 0xeade, 0x433d, [0x86, 0x2e, 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44]); @@ -13,12 +8,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..3c9d866 100644 --- a/src/security.rs +++ b/src/security.rs @@ -1,17 +1,14 @@ +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}, }; use crate::display::{Display, Output}; @@ -228,7 +225,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 +338,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..92221a1 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -1,10 +1,9 @@ // SPDX-License-Identifier: GPL-3.0-only 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 +14,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..c983c81 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -1,7 +1,9 @@ +use core::ptr; + use orbclient::{Color, Renderer}; use orbfont::{Font, Text}; -use std::ptr; -use std::uefi::status::{Error, Result}; + +use std::prelude::*; use crate::display::Display; use crate::image::{self, Image}; @@ -39,7 +41,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 +55,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 +69,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));