Skip to content

Commit

Permalink
seed_uefi: deserialize config with picotoml
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacWoods committed Sep 21, 2023
1 parent 0a21150 commit e3b5237
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 1 deletion.
80 changes: 80 additions & 0 deletions seed/Cargo.lock

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

2 changes: 2 additions & 0 deletions seed/seed_uefi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ mer = { path = "../../lib/mer" }
gfxconsole = { path = "../../lib/gfxconsole" }
poplar_util = { path = "../../lib/poplar_util" }
heapless = "0.7.16"
serde = { version = "1.0.188", default-features = false, features = ["derive", "alloc"] }
picotoml = { path = "../../lib/picotoml" }
12 changes: 11 additions & 1 deletion seed/seed_uefi/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@
#![no_main]
#![feature(panic_info_message, cell_update, never_type)]

extern crate alloc;

mod allocator;
mod image;
mod logger;

use alloc::{string::String, vec::Vec};
use allocator::BootFrameAllocator;
use core::{arch::asm, mem, panic::PanicInfo, ptr};
use hal::memory::{kibibytes, Bytes, Flags, FrameAllocator, FrameSize, PAddr, Page, PageTable, Size4KiB, VAddr};
use hal_x86_64::paging::PageTableImpl;
use log::{error, info};
use logger::Logger;
use seed::boot_info::{BootInfo, VideoModeInfo};
use serde::Deserialize;
use uefi::{
prelude::*,
proto::{console::gop::GraphicsOutput, loaded_image::LoadedImage},
table::boot::{AllocateType, MemoryType, SearchType},
CStr16,
};

/*
Expand All @@ -33,6 +36,11 @@ pub const KERNEL_HEAP_MEMORY_TYPE: MemoryType = MemoryType::custom(0x80000005);

const KERNEL_HEAP_SIZE: Bytes = kibibytes(800);

#[derive(Clone, Debug, Deserialize)]
struct SeedConfig {
pub user_tasks: Vec<String>,
}

#[entry]
fn efi_main(image_handle: Handle, system_table: SystemTable<Boot>) -> Status {
Logger::init();
Expand Down Expand Up @@ -69,6 +77,8 @@ fn efi_main(image_handle: Handle, system_table: SystemTable<Boot>) -> Status {
let mut filesystem = uefi::fs::FileSystem::new(root_file_protocol);
let config = filesystem.read(Path::new(&CString16::try_from("config.toml").unwrap())).unwrap();
info!("Config: {}", core::str::from_utf8(&config).unwrap());
let config_deser: SeedConfig = picotoml::from_str(core::str::from_utf8(&config).unwrap()).unwrap();
info!("Config deser: {:?}", config_deser);
}

let kernel_info = {
Expand Down

0 comments on commit e3b5237

Please sign in to comment.