Skip to content

Commit

Permalink
Update redox_uefi_std
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Crawford <[email protected]>
  • Loading branch information
crawfxrd committed May 30, 2024
1 parent 33bf2f3 commit 1703c37
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 59 deletions.
21 changes: 9 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions src/display.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -53,7 +53,7 @@ impl Display {
h as usize,
0
);
status.branch().is_continue()
status.is_success()
}
}

Expand Down
23 changes: 10 additions & 13 deletions src/fde.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -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};
Expand Down Expand Up @@ -47,15 +47,15 @@ impl HiiStringProtocol {
pub fn string(&self, PackageList: HiiHandle, StringId: StringId) -> Result<String> {
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,
StringId,
data.as_mut_ptr(),
&mut len,
0
)?;
))?;
data.truncate(len);

let mut string = String::new();
Expand Down Expand Up @@ -354,7 +354,7 @@ fn wait_for_events(form: &Form) -> Result<EventType> {
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)
Expand Down Expand Up @@ -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),
}
};
Expand Down Expand Up @@ -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() {
Expand All @@ -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)
};

Expand Down
2 changes: 2 additions & 0 deletions src/image/bmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

use super::Image;

use std::prelude::*;

pub fn parse(file_data: &[u8]) -> Result<Image, String> {
use orbclient::Color;

Expand Down
4 changes: 3 additions & 1 deletion src/image/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
4 changes: 2 additions & 2 deletions src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ pub fn raw_key(wait: bool) -> Result<TextInputKey> {

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 {
ScanCode: 0,
UnicodeChar: 0
};

(uefi.ConsoleIn.ReadKeyStroke)(uefi.ConsoleIn, &mut key)?;
Result::from((uefi.ConsoleIn.ReadKeyStroke)(uefi.ConsoleIn, &mut key))?;

Ok(key)
}
Expand Down
8 changes: 0 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/rng.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core::ptr;
use std::{
proto::Protocol,
ptr,
};
use std::uefi::{
guid::Guid,
Expand All @@ -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(())
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/security.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -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(())
}
4 changes: 2 additions & 2 deletions src/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,7 +15,7 @@ bitflags! {
}
}

bitflags! {
bitflags::bitflags! {
/// Line status flags
struct LineStsFlags: u8 {
const INPUT_FULL = 1;
Expand Down
13 changes: 8 additions & 5 deletions src/ui.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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));
Expand All @@ -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));
Expand All @@ -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));
Expand Down

0 comments on commit 1703c37

Please sign in to comment.