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 #109

Merged
merged 3 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
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

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

Expand All @@ -16,10 +16,11 @@ jobs:
- name: clippy
env:
BASEDIR: "."
run: cargo clippy
run: cargo clippy --target x86_64-unknown-uefi -- -D warnings
continue-on-error: true

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

Expand Down
44 changes: 22 additions & 22 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 @@ -15,7 +15,7 @@ plain = "0.2.3"
redox_dmi = "0.1.6"
redox_hwio = { version = "0.1.6", default-features = false }
redox_intelflash = "0.1.3"
redox_uefi_std = "0.1.12"
redox_uefi_std = "0.1.13"
system76_ecflash = "0.1.3"

[dependencies.system76_ectool]
Expand Down
21 changes: 10 additions & 11 deletions src/app/bios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ use alloc::collections::BTreeMap;
use alloc::string::String;
use core::arch::asm;
use core::char;
use core::ptr;
use coreboot_fs::Rom;
use ecflash::EcFlash;
use intel_spi::{HsfStsCtl, Spi, SpiDev};
use plain::Plain;
use std::fs::{find, load};
use std::prelude::*;
use std::ptr;
use std::uefi::reset::ResetType;
use std::uefi::status::{Error, Result, Status};
use std::vars::{get_boot_item, get_boot_order, set_boot_item, set_boot_order};

use super::{
Expand Down Expand Up @@ -224,7 +223,7 @@ impl Component for BiosComponent {
// Self::spi_unlock();
// }

let len = spi.len().map_err(|_| Error::DeviceError)?;
let len = spi.len().map_err(|_| Status::DEVICE_ERROR)?;
Ok(data.len() == len)
} else if self.capsule {
Ok(true)
Expand Down Expand Up @@ -290,11 +289,11 @@ impl Component for BiosComponent {
}

// Check ROM size
let len = spi.len().map_err(|_| Error::DeviceError)?;
let len = spi.len().map_err(|_| Status::DEVICE_ERROR)?;
println!("SPI ROM: {} MB", len / (1024 * 1024));
if len != new.len() {
println!("firmware.rom size invalid");
return Err(Error::DeviceError);
return Err(Status::DEVICE_ERROR);
}

// Read current data
Expand All @@ -306,7 +305,7 @@ impl Component for BiosComponent {
let mut buf = [0; 4096];
let read = spi
.read(data.len(), &mut buf)
.map_err(|_| Error::DeviceError)?;
.map_err(|_| Status::DEVICE_ERROR)?;
data.extend_from_slice(&buf[..read]);

// Print output once per megabyte
Expand All @@ -325,7 +324,7 @@ impl Component for BiosComponent {
Ok(false) => (),
Err(err) => {
println!("Ethernet: failed to copy: {}", err);
return Err(Error::DeviceError);
return Err(Status::DEVICE_ERROR);
}
}

Expand Down Expand Up @@ -376,7 +375,7 @@ impl Component for BiosComponent {
);
let new_slice = new
.get_mut(new_offset..new_offset + new_size)
.ok_or(Error::DeviceError)?;
.ok_or(Status::DEVICE_ERROR)?;

if let Some(area) = areas.get(area_name) {
let offset = area.offset as usize;
Expand All @@ -387,7 +386,7 @@ impl Component for BiosComponent {
new_offset,
new_size / 1024
);
let slice = data.get(offset..offset + size).ok_or(Error::DeviceError)?;
let slice = data.get(offset..offset + size).ok_or(Status::DEVICE_ERROR)?;

if slice.len() == new_slice.len() {
new_slice.copy_from_slice(slice);
Expand Down Expand Up @@ -471,7 +470,7 @@ impl Component for BiosComponent {
"\nverification failed as {:#x}: {:#x} != {:#x}",
address, data[address], new[address]
);
return Err(Error::DeviceError);
return Err(Status::DEVICE_ERROR);
}
address += 1;
}
Expand Down Expand Up @@ -547,7 +546,7 @@ impl Component for BiosComponent {

if status != 0 {
println!("{} Flash Error: {}", self.name(), status);
return Err(Error::DeviceError);
return Err(Status::DEVICE_ERROR);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/component.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only

use std::uefi::status::Result;
use std::prelude::*;

pub trait Component {
fn name(&self) -> &str;
Expand Down
29 changes: 13 additions & 16 deletions src/app/ec.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
// SPDX-License-Identifier: GPL-3.0-only

use core::ops::{ControlFlow, Try};
use ecflash::{Ec, EcFile, EcFlash};
use ectool::{timeout, Access, AccessLpcDirect, Firmware, SecurityState, Spi, SpiRom, SpiTarget, Timeout};
use plain::Plain;
use std::prelude::*;
use std::uefi::{
self,
reset::ResetType,
status::{Error, Result, Status},
};
use core::cell::Cell;
use core::ptr;
use core::str;
use std::{
cell::Cell,
ffi::wstr,
fs::{find, load},
ptr,
str,
};

use super::{pci_read, shell, Component, EC2ROM, ECROM, ECTAG, FIRMWAREDIR, FIRMWARENSH, sideband::Sideband};
Expand Down Expand Up @@ -745,7 +743,7 @@ impl Component for EcComponent {
Ok(())
} else {
println!("{} Flash Error: {}", self.name(), status);
Err(Error::DeviceError)
Err(Status::DEVICE_ERROR)
}
},
EcKind::System76(_ec, _pmc) => {
Expand All @@ -757,7 +755,7 @@ impl Component for EcComponent {
Ok(()) => Ok(()),
Err(err) => {
println!("{} Flash Error: {:X?}", self.name(), err);
Err(Error::DeviceError)
Err(Status::DEVICE_ERROR)
}
}
}
Expand All @@ -769,13 +767,13 @@ impl Component for EcComponent {
Ok(()) => Ok(()),
Err(err) => {
println!("{} Flash Error: {:X?}", self.name(), err);
Err(Error::DeviceError)
Err(Status::DEVICE_ERROR)
}
}
}
EcKind::Unknown => {
println!("{} Failed to flash EcKind::Unknown", self.name());
Err(Error::DeviceError)
Err(Status::DEVICE_ERROR)
}
};

Expand All @@ -784,7 +782,7 @@ impl Component for EcComponent {
Ok((_, firmware_dir)) => {
//Try to create tag file without running shell
let filename = wstr(ECTAG);
let mut file = std::ptr::null_mut::<uefi::fs::File>();
let mut file = ptr::null_mut::<uefi::fs::File>();
match (firmware_dir.0.Open)(
firmware_dir.0,
&mut file,
Expand All @@ -794,16 +792,15 @@ impl Component for EcComponent {
| uefi::fs::FILE_MODE_WRITE,
0,
)
.branch()
{
ControlFlow::Continue(_) => {
Status::SUCCESS => {
unsafe {
let _ = ((*file).Close)(&mut *file);
}
println!("EC tag: created successfully");
}
ControlFlow::Break(err) => {
println!("EC tag: failed to create {}: {:?}", ECTAG, err);
err => {
println!("EC tag: failed to create {}: {}", ECTAG, err);
}
}
}
Expand Down Expand Up @@ -836,9 +833,9 @@ fn memory_kind() -> Result<u8> {
if let Ok(info) = dmi::MemoryDevice::from_bytes(&table.data) {
return Ok(info.memory_kind);
} else {
return Err(Error::DeviceError);
return Err(Status::DEVICE_ERROR);
}
}

Err(Error::DeviceError)
Err(Status::DEVICE_ERROR)
}
Loading
Loading