Skip to content
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

Update redox_uefi_std to 0.1.13 #17

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

Expand Down
12 changes: 6 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 = "0.1.13"
23 changes: 12 additions & 11 deletions src/gop_policy.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
// 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};

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

pub static GOP_POLICY_GUID: Guid = Guid(0xec2e931b,0x3281,0x48a5,[0x81,0x7,0xdf,0x8a,0x8b,0xed,0x3c,0x5d]);
pub static GOP_POLICY_GUID: Guid = guid!("ec2e931b-3281-48a5-8107-df8a8bed3c5d");
pub const GOP_POLICY_REVISION: u32 = 0x03;

#[allow(unused)]
Expand All @@ -31,18 +27,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 +48,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 All @@ -71,7 +67,7 @@ impl GopPolicy {
GetPlatformLidStatus,
GetVbtData,
GetPlatformDockStatus,
GopOverrideGuid: NULL_GUID,
GopOverrideGuid: Guid::NULL,
})
}

Expand All @@ -80,7 +76,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
8 changes: 2 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,22 @@

#![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;

#[no_mangle]
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
}
}