stub: use logger instead of printing manually

This commit is contained in:
Julian Stecklina 2023-02-21 01:28:25 +01:00
parent 7bde42f4a8
commit 90755b789f
1 changed files with 15 additions and 26 deletions

View File

@ -12,13 +12,13 @@ mod pe_section;
mod uefi_helpers; mod uefi_helpers;
use alloc::vec::Vec; use alloc::vec::Vec;
use log::{info, warn};
use pe_loader::Image; use pe_loader::Image;
use pe_section::{pe_section, pe_section_as_string}; use pe_section::{pe_section, pe_section_as_string};
use sha2::{Digest, Sha256}; use sha2::{Digest, Sha256};
use uefi::{ use uefi::{
prelude::*, prelude::*,
proto::{ proto::{
console::text::Output,
loaded_image::LoadedImage, loaded_image::LoadedImage,
media::file::{File, FileAttribute, FileMode, RegularFile}, media::file::{File, FileAttribute, FileMode, RegularFile},
}, },
@ -33,20 +33,18 @@ use crate::{
type Hash = sha2::digest::Output<Sha256>; type Hash = sha2::digest::Output<Sha256>;
/// Print the startup logo on boot. /// Print the startup logo on boot.
fn print_logo(output: &mut Output) -> Result<()> { fn print_logo() {
output.clear()?; info!(
output.output_string(cstr16!(
" "
_ _ _\r _ _ _
| | | | | |\r | | | | | |
| | __ _ _ __ ______ _| |__ ___ ___ | |_ ___\r | | __ _ _ __ ______ _| |__ ___ ___ | |_ ___
| |/ _` | '_ \\|_ / _` | '_ \\ / _ \\ / _ \\| __/ _ \\\r | |/ _` | '_ \\|_ / _` | '_ \\ / _ \\ / _ \\| __/ _ \\
| | (_| | | | |/ / (_| | |_) | (_) | (_) | || __/\r | | (_| | | | |/ / (_| | |_) | (_) | (_) | || __/
|_|\\__,_|_| |_/___\\__,_|_.__/ \\___/ \\___/ \\__\\___|\r |_|\\__,_|_| |_/___\\__,_|_.__/ \\___/ \\___/ \\__\\___|
\r
" "
)) );
} }
/// The configuration that is embedded at build time. /// The configuration that is embedded at build time.
@ -180,7 +178,7 @@ fn boot_linux_uefi(
fn main(handle: Handle, mut system_table: SystemTable<Boot>) -> Status { fn main(handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
uefi_services::init(&mut system_table).unwrap(); uefi_services::init(&mut system_table).unwrap();
print_logo(system_table.stdout()).unwrap(); print_logo();
let config: EmbeddedConfiguration = let config: EmbeddedConfiguration =
EmbeddedConfiguration::new(&mut booted_image_file(system_table.boot_services()).unwrap()) EmbeddedConfiguration::new(&mut booted_image_file(system_table.boot_services()).unwrap())
@ -227,17 +225,11 @@ fn main(handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
let is_initrd_hash_correct = Sha256::digest(&initrd_data) == config.initrd_hash; let is_initrd_hash_correct = Sha256::digest(&initrd_data) == config.initrd_hash;
if !is_kernel_hash_correct { if !is_kernel_hash_correct {
system_table warn!("Hash mismatch for kernel!");
.stdout()
.output_string(cstr16!("Hash mismatch for kernel!\r\n"))
.unwrap();
} }
if !is_initrd_hash_correct { if !is_initrd_hash_correct {
system_table warn!("Hash mismatch for initrd!");
.stdout()
.output_string(cstr16!("Hash mismatch for initrd!\r\n"))
.unwrap();
} }
if is_kernel_hash_correct && is_initrd_hash_correct { if is_kernel_hash_correct && is_initrd_hash_correct {
@ -271,10 +263,7 @@ fn main(handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
// of the firmware is broken, we have little hope of security // of the firmware is broken, we have little hope of security
// anyway. // anyway.
system_table warn!("Trying to continue as non-Secure Boot. This will fail when Secure Boot is enabled.");
.stdout()
.output_string(cstr16!("WARNING: Trying to continue as non-Secure Boot. This will fail when Secure Boot is enabled.\r\n"))
.unwrap();
boot_linux_uefi( boot_linux_uefi(
handle, handle,