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 <tcrawford@system76.com>
  • Loading branch information
crawfxrd committed May 30, 2024
1 parent 61a9e9f commit 97aec68
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
9 changes: 3 additions & 6 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 @@ -8,4 +8,4 @@ license = "GPL-3.0-only"
lto = true

[dependencies]
redox_uefi_std = "0.1.12"
redox_uefi_std = { git = "https://gitlab.redox-os.org/tcrawford/uefi", branch = "stable" }
18 changes: 11 additions & 7 deletions src/gop_policy.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// SPDX-License-Identifier: GPL-3.0-only

use core::ops::FromResidual;
use std::prelude::*;
use std::uefi::Handle;
use std::uefi::boot::InterfaceType;
use std::uefi::guid::{Guid, NULL_GUID};
use std::uefi::memory::PhysicalAddress;
use std::uefi::status::{Error, Result, Status};
use std::uefi::status::{Result, Status};

static VBT: &[u8] = include_bytes!(env!("FIRMWARE_OPEN_VBT"));

Expand All @@ -31,18 +30,18 @@ pub enum DockStatus {

extern "win64" fn GetPlatformLidStatus(CurrentLidStatus: *mut LidStatus) -> Status {
if CurrentLidStatus.is_null() {
return Status::from_residual(Error::InvalidParameter);
return Status::INVALID_PARAMETER;
}

// TODO: Get real lid status
unsafe { *CurrentLidStatus = LidStatus::LidOpen };

Status(0)
Status::SUCCESS
}

extern "win64" fn GetVbtData(VbtAddress: *mut PhysicalAddress, VbtSize: *mut u32) -> Status {
if VbtAddress.is_null() || VbtSize.is_null() {
return Status::from_residual(Error::InvalidParameter);
return Status::INVALID_PARAMETER;
}

unsafe { *VbtAddress = PhysicalAddress(VBT.as_ptr() as u64) };
Expand All @@ -52,7 +51,7 @@ extern "win64" fn GetVbtData(VbtAddress: *mut PhysicalAddress, VbtSize: *mut u32
}

extern "win64" fn GetPlatformDockStatus(_CurrentDockStatus: DockStatus) -> Status {
Status::from_residual(Error::Unsupported)
Status::UNSUPPORTED
}

#[repr(C)]
Expand Down Expand Up @@ -80,7 +79,12 @@ impl GopPolicy {

let self_ptr = Box::into_raw(self);
let mut handle = Handle(0);
(uefi.BootServices.InstallProtocolInterface)(&mut handle, &GOP_POLICY_GUID, InterfaceType::Native, self_ptr as usize)?;
Result::from((uefi.BootServices.InstallProtocolInterface)(
&mut handle,
&GOP_POLICY_GUID,
InterfaceType::Native,
self_ptr as usize
))?;

//let _ = (uefi.BootServices.UninstallProtocolInterface)(handle, &GOP_POLICY_GUID, self_ptr as usize);

Expand Down
6 changes: 2 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

#![no_std]
#![no_main]
#![feature(try_trait_v2)]
#![allow(non_snake_case)]

#[macro_use]
extern crate uefi_std as std;

use std::prelude::*;

use core::ops::FromResidual;
use std::uefi::status::Status;

mod gop_policy;
Expand All @@ -20,8 +18,8 @@ pub extern "C" fn main() -> Status {
let gop_policy = gop_policy::GopPolicy::new();
if let Err(err) = gop_policy.install() {
println!("GopPolicy error: {:?}", err);
Status::from_residual(err)
err
} else {
Status(0)
Status::SUCCESS
}
}

0 comments on commit 97aec68

Please sign in to comment.