diff --git a/Cargo.lock b/Cargo.lock index 12771e5de8..a359c752cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -325,17 +325,12 @@ name = "boot_info" version = "0.1.0" dependencies = [ "bitflags", - "bootloader_api", "kernel_config", "memory_structs", "multiboot2", + "uefi-bootloader-api", ] -[[package]] -name = "bootloader_api" -version = "0.11.0" -source = "git+https://github.com/theseus-os/bootloader?branch=theseus#6cc130e2f9dc633445846a1e2c4d961b1daddd78" - [[package]] name = "bootloader_modules" version = "0.1.0" @@ -2166,7 +2161,6 @@ name = "nano_core" version = "0.1.0" dependencies = [ "boot_info", - "bootloader_api", "captain", "cfg-if 1.0.0", "exceptions_early", @@ -2184,6 +2178,7 @@ dependencies = [ "serial_port_basic", "stack", "state_store", + "uefi-bootloader-api", "vga_buffer", ] @@ -4021,6 +4016,11 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +[[package]] +name = "uefi-bootloader-api" +version = "0.1.0" +source = "git+https://github.com/theseus-os/uefi-bootloader#1aeb6f29bf2f3cc2cd2ab2dee893bef5caa1f96c" + [[package]] name = "unicode-ident" version = "1.0.1" diff --git a/Makefile b/Makefile index 3bbe7bc620..df969cb2ba 100644 --- a/Makefile +++ b/Makefile @@ -193,7 +193,7 @@ ifeq ($(boot_spec), uefi) --release \ -Z bindeps \ --manifest-path \ - $(ROOT_DIR)/tools/uefi_builder/Cargo.toml -- \ + $(ROOT_DIR)/tools/uefi_builder/x86_64/Cargo.toml -- \ --kernel $(nano_core_binary) \ --modules $(OBJECT_FILES_BUILD_DIR) \ --efi-image $(iso) \ diff --git a/kernel/boot_info/Cargo.toml b/kernel/boot_info/Cargo.toml index 58d1b92507..835a0ce11a 100644 --- a/kernel/boot_info/Cargo.toml +++ b/kernel/boot_info/Cargo.toml @@ -11,11 +11,10 @@ kernel_config = { path = "../kernel_config" } memory_structs = { path = "../memory_structs" } multiboot2 = { version = "0.14", optional = true } -[dependencies.bootloader_api] -git = "https://github.com/theseus-os/bootloader" -branch = "theseus" +[dependencies.uefi-bootloader-api] +git = "https://github.com/theseus-os/uefi-bootloader" optional = true [features] -uefi = ["dep:bootloader_api"] +uefi = ["dep:uefi-bootloader-api"] multiboot2 = ["dep:multiboot2"] diff --git a/kernel/boot_info/src/lib.rs b/kernel/boot_info/src/lib.rs index 795cc12d26..7da49a2eb1 100644 --- a/kernel/boot_info/src/lib.rs +++ b/kernel/boot_info/src/lib.rs @@ -38,7 +38,8 @@ pub trait ElfSection { /// Returns the section's starting virtual address. fn start(&self) -> VirtualAddress; - /// Returns the section's length. + /// Returns the section's length in memory, as opposed to its length in the + /// ELF file. fn len(&self) -> usize; /// Returns whether the section is empty. @@ -121,8 +122,8 @@ pub trait BootInformation: 'static { &self, ) -> Result; - /// Returns the end of the kernel's image in physical memory. - fn kernel_end(&self) -> Result; + /// Returns the end of the kernel's image in memory. + fn kernel_end(&self) -> Result; /// Returns the RSDP if it was provided by the bootloader. fn rsdp(&self) -> Option; diff --git a/kernel/boot_info/src/multiboot2.rs b/kernel/boot_info/src/multiboot2.rs index ebb21111da..8b244eeb0c 100644 --- a/kernel/boot_info/src/multiboot2.rs +++ b/kernel/boot_info/src/multiboot2.rs @@ -196,9 +196,12 @@ impl crate::BootInformation for multiboot2::BootInformation { .into_iter()) } - fn kernel_end(&self) -> Result { - let reserved_region = kernel_memory_region(self)?; - Ok(reserved_region.start + reserved_region.len) + fn kernel_end(&self) -> Result { + use crate::ElfSection; + self.elf_sections()? + .map(|section| section.start() + section.len()) + .max() + .ok_or("no elf sections") } fn rsdp(&self) -> Option { diff --git a/kernel/boot_info/src/uefi.rs b/kernel/boot_info/src/uefi.rs index 455bcd60aa..aa8145bf90 100644 --- a/kernel/boot_info/src/uefi.rs +++ b/kernel/boot_info/src/uefi.rs @@ -1,7 +1,6 @@ use crate::ElfSectionFlags; -use bootloader_api::info; use core::iter::{Iterator, Peekable}; -use kernel_config::memory::{KERNEL_OFFSET, KERNEL_STACK_SIZE_IN_PAGES, PAGE_SIZE}; +use kernel_config::memory::{KERNEL_STACK_SIZE_IN_PAGES, PAGE_SIZE}; use memory_structs::{PhysicalAddress, VirtualAddress}; // TODO: Ideally this would be defined in nano_core. However, that would @@ -11,27 +10,12 @@ use memory_structs::{PhysicalAddress, VirtualAddress}; pub const STACK_SIZE: usize = (KERNEL_STACK_SIZE_IN_PAGES + 2) * PAGE_SIZE; /// A custom memory region kind used by the bootloader for the modules. -const MODULES_MEMORY_KIND: info::MemoryRegionKind = info::MemoryRegionKind::UnknownUefi(0x80000000); +const MODULES_MEMORY_KIND: uefi_bootloader_api::MemoryRegionKind = + uefi_bootloader_api::MemoryRegionKind::UnknownUefi(0x80000000); -pub struct MemoryRegion { - start: PhysicalAddress, - len: usize, - is_usable: bool, -} - -impl From for MemoryRegion { - fn from(info::MemoryRegion { start, end, kind }: info::MemoryRegion) -> Self { - Self { - start: PhysicalAddress::new_canonical(start as usize), - len: (end - start) as usize, - is_usable: matches!(kind, info::MemoryRegionKind::Usable), - } - } -} - -impl crate::MemoryRegion for MemoryRegion { +impl crate::MemoryRegion for uefi_bootloader_api::MemoryRegion { fn start(&self) -> PhysicalAddress { - self.start + PhysicalAddress::new_canonical(self.start) } fn len(&self) -> usize { @@ -39,38 +23,37 @@ impl crate::MemoryRegion for MemoryRegion { } fn is_usable(&self) -> bool { - self.is_usable + matches!(self.kind, uefi_bootloader_api::MemoryRegionKind::Usable) } } -pub struct MemoryRegions { - inner: Peekable>, +pub struct MemoryRegions<'a> { + inner: Peekable>, } -impl Iterator for MemoryRegions { - type Item = MemoryRegion; +impl<'a> Iterator for MemoryRegions<'a> { + type Item = uefi_bootloader_api::MemoryRegion; fn next(&mut self) -> Option { - let mut area: MemoryRegion = (*self.inner.next()?).into(); + let mut region = *self.inner.next()?; // UEFI often separates contiguous memory into separate memory regions. We // consolidate them to minimise the number of entries in the frame allocator's // reserved and available lists. - while let Some(next) = self.inner.next_if(|next| { - let next = MemoryRegion::from(**next); - area.is_usable == next.is_usable && (area.start + area.len) == next.start - }) { - let next = MemoryRegion::from(*next); - area.len += next.len; + while let Some(next) = self + .inner + .next_if(|next| region.kind == next.kind && (region.start + region.len) == next.start) + { + region.len += next.len; } - Some(area) + Some(region) } } -impl<'a> crate::ElfSection for &'a info::ElfSection { +impl<'a> crate::ElfSection for &'a uefi_bootloader_api::ElfSection { fn name(&self) -> &str { - info::ElfSection::name(self) + uefi_bootloader_api::ElfSection::name(self) } fn start(&self) -> VirtualAddress { @@ -86,14 +69,15 @@ impl<'a> crate::ElfSection for &'a info::ElfSection { } } +#[derive(Debug)] pub struct Module { - inner: info::Module, - regions: &'static info::MemoryRegions, + inner: uefi_bootloader_api::Module, + regions: &'static uefi_bootloader_api::MemoryRegions, } impl crate::Module for Module { fn name(&self) -> Result<&str, &'static str> { - Ok(info::Module::name(&self.inner)) + Ok(uefi_bootloader_api::Module::name(&self.inner)) } fn start(&self) -> PhysicalAddress { @@ -113,8 +97,8 @@ impl crate::Module for Module { } pub struct Modules { - inner: &'static info::Modules, - regions: &'static info::MemoryRegions, + inner: &'static uefi_bootloader_api::Modules, + regions: &'static uefi_bootloader_api::MemoryRegions, index: usize, } @@ -132,12 +116,12 @@ impl Iterator for Modules { } } -impl crate::BootInformation for &'static bootloader_api::BootInfo { - type MemoryRegion<'a> = MemoryRegion; - type MemoryRegions<'a> = MemoryRegions; +impl crate::BootInformation for &'static uefi_bootloader_api::BootInformation { + type MemoryRegion<'a> = uefi_bootloader_api::MemoryRegion; + type MemoryRegions<'a> = MemoryRegions<'a>; - type ElfSection<'a> = &'a info::ElfSection; - type ElfSections<'a> = core::slice::Iter<'a, info::ElfSection>; + type ElfSection<'a> = &'a uefi_bootloader_api::ElfSection; + type ElfSections<'a> = core::slice::Iter<'a, uefi_bootloader_api::ElfSection>; type Module<'a> = Module; type Modules<'a> = Modules; @@ -176,24 +160,23 @@ impl crate::BootInformation for &'static bootloader_api::BootInfo { Ok(core::iter::empty()) } - fn kernel_end(&self) -> Result { + fn kernel_end(&self) -> Result { use crate::ElfSection; - PhysicalAddress::new( + VirtualAddress::new( self.elf_sections()? .filter(|section| section.flags().contains(ElfSectionFlags::ALLOCATED)) + .filter(|section| section.size > 0) .map(|section| section.start + section.size) .max() - .ok_or("couldn't find kernel end address")? as usize - - KERNEL_OFFSET, + .ok_or("couldn't find kernel end address")? as usize, ) - .ok_or("kernel physical end address was invalid") + .ok_or("kernel virtual end address was invalid") } fn rsdp(&self) -> Option { - self.rsdp_addr - .into_option() - .map(|address| PhysicalAddress::new_canonical(address as usize)) + self.rsdp_address + .map(|address| PhysicalAddress::new_canonical(address)) } fn stack_size(&self) -> Result { diff --git a/kernel/captain/src/lib.rs b/kernel/captain/src/lib.rs index fe37b120d3..d803422d79 100644 --- a/kernel/captain/src/lib.rs +++ b/kernel/captain/src/lib.rs @@ -85,6 +85,7 @@ pub fn init( bsp_initial_stack: NoDrop, ap_start_realmode_begin: VirtualAddress, ap_start_realmode_end: VirtualAddress, + ap_gdt: VirtualAddress, rsdp_address: Option, ) -> Result<(), &'static str> { #[cfg(mirror_log_to_vga)] @@ -128,6 +129,7 @@ pub fn init( &kernel_mmi_ref, ap_start_realmode_begin, ap_start_realmode_end, + ap_gdt, Some(kernel_config::display::FRAMEBUFFER_MAX_RESOLUTION), )?; let cpu_count = ap_count + 1; diff --git a/kernel/memory/src/lib.rs b/kernel/memory/src/lib.rs index b766dd7c95..23e3d0c4c2 100644 --- a/kernel/memory/src/lib.rs +++ b/kernel/memory/src/lib.rs @@ -21,6 +21,7 @@ mod paging; pub use self::paging::{ PageTable, Mapper, Mutability, Mutable, Immutable, MappedPages, BorrowedMappedPages, BorrowedSliceMappedPages, + translate, }; pub use memory_structs::{Frame, Page, FrameRange, PageRange, VirtualAddress, PhysicalAddress}; @@ -220,7 +221,18 @@ pub fn init( debug!("Initialized new frame allocator!"); frame_allocator::dump_frame_allocator_state(); - page_allocator::init(VirtualAddress::new_canonical(boot_info.kernel_end()?.value()))?; + page_allocator::init( + VirtualAddress::new( + // We subtract 1 when translating because `kernel_end` returns an exclusive + // upper bound, which can cause problems if the kernel ends on a page boundary. + // We then add it back later to get the correct identity virtual address. + translate(boot_info.kernel_end()? - 1) + .ok_or("couldn't translate kernel end virtual address")? + .value() + + 1, + ) + .ok_or("couldn't convert kernel end physical address into virtual address")?, + )?; debug!("Initialized new page allocator!"); page_allocator::dump_page_allocator_state(); diff --git a/kernel/memory/src/paging/mapper.rs b/kernel/memory/src/paging/mapper.rs index bc515ebd43..611493c483 100644 --- a/kernel/memory/src/paging/mapper.rs +++ b/kernel/memory/src/paging/mapper.rs @@ -50,6 +50,11 @@ use owned_borrowed_trait::{OwnedOrBorrowed, Owned, Borrowed}; /// that it is only invoked for `UnmappedFrames`. pub(super) static INTO_ALLOCATED_FRAMES_FUNC: Once AllocatedFrames> = Once::new(); +/// A convenience function to translate the given virtual address into a +/// physical address using the currently-active page table. +pub fn translate(virtual_address: VirtualAddress) -> Option { + Mapper::from_current().translate(virtual_address) +} pub struct Mapper { p4: Unique>, diff --git a/kernel/memory/src/paging/mod.rs b/kernel/memory/src/paging/mod.rs index 700170fa0e..999733d9de 100644 --- a/kernel/memory/src/paging/mod.rs +++ b/kernel/memory/src/paging/mod.rs @@ -19,7 +19,7 @@ pub use self::{ temporary_page::TemporaryPage, mapper::{ Mapper, MappedPages, BorrowedMappedPages, BorrowedSliceMappedPages, - Mutability, Mutable, Immutable, + Mutability, Mutable, Immutable, translate, }, }; @@ -216,14 +216,14 @@ pub fn init( // `page_table_entry::UnmappedFrames` back into `AllocatedFrames`. mapper::INTO_ALLOCATED_FRAMES_FUNC.call_once(|| into_alloc_frames_fn); - let (aggregated_section_memory_bounds, _sections_memory_bounds) = find_section_memory_bounds(boot_info)?; - debug!("{:X?}\n{:X?}", aggregated_section_memory_bounds, _sections_memory_bounds); - // bootstrap a PageTable from the currently-loaded page table let mut page_table = PageTable::from_current() .map_err(|_| "Failed to allocate frame for initial page table; is it merged with another section?")?; debug!("Bootstrapped initial {:?}", page_table); + let (aggregated_section_memory_bounds, _sections_memory_bounds) = find_section_memory_bounds(boot_info, |virtual_address| page_table.translate(virtual_address))?; + debug!("{:X?}\n{:X?}", aggregated_section_memory_bounds, _sections_memory_bounds); + let boot_info_start_vaddr = boot_info.start().ok_or("boot_info start virtual address was invalid")?; let boot_info_start_paddr = page_table.translate(boot_info_start_vaddr).ok_or("Couldn't get boot_info start physical address")?; let boot_info_size = boot_info.len(); @@ -303,7 +303,10 @@ pub fn init( let text_pages = page_allocator::allocate_pages_by_bytes_at(text_start_virt, text_end_virt.value() - text_start_virt.value())?; let text_frames = frame_allocator::allocate_frames_by_bytes_at(text_start_phys, text_end_phys.value() - text_start_phys.value())?; - let text_pages_identity = page_allocator::allocate_pages_by_bytes_at(text_start_virt - KERNEL_OFFSET, text_end_virt.value() - text_start_virt.value())?; + let text_pages_identity = page_allocator::allocate_pages_by_bytes_at( + VirtualAddress::new_canonical(text_start_phys.value()), + text_end_phys.value() - text_start_phys.value(), + )?; text_identity_mapped_pages = NoDrop::new( unsafe { Mapper::map_to_non_exclusive(new_mapper, text_pages_identity, &text_frames, text_flags)? }); @@ -312,7 +315,10 @@ pub fn init( let rodata_pages = page_allocator::allocate_pages_by_bytes_at(rodata_start_virt, rodata_end_virt.value() - rodata_start_virt.value())?; let rodata_frames = frame_allocator::allocate_frames_by_bytes_at(rodata_start_phys, rodata_end_phys.value() - rodata_start_phys.value())?; - let rodata_pages_identity = page_allocator::allocate_pages_by_bytes_at(rodata_start_virt - KERNEL_OFFSET, rodata_end_virt.value() - rodata_start_virt.value())?; + let rodata_pages_identity = page_allocator::allocate_pages_by_bytes_at( + VirtualAddress::new_canonical(rodata_start_phys.value()), + rodata_end_phys.value() - rodata_start_phys.value(), + )?; rodata_identity_mapped_pages = NoDrop::new( unsafe { Mapper::map_to_non_exclusive(new_mapper, rodata_pages_identity, &rodata_frames, rodata_flags)? }); @@ -320,7 +326,10 @@ pub fn init( let data_pages = page_allocator::allocate_pages_by_bytes_at(data_start_virt, data_end_virt.value() - data_start_virt.value())?; let data_frames = frame_allocator::allocate_frames_by_bytes_at(data_start_phys, data_end_phys.value() - data_start_phys.value())?; - let data_pages_identity = page_allocator::allocate_pages_by_bytes_at(data_start_virt - KERNEL_OFFSET, data_end_virt.value() - data_start_virt.value())?; + let data_pages_identity = page_allocator::allocate_pages_by_bytes_at( + VirtualAddress::new_canonical(data_start_phys.value()), + data_end_phys.value() - data_start_phys.value(), + )?; data_identity_mapped_pages = NoDrop::new( unsafe { Mapper::map_to_non_exclusive(new_mapper, data_pages_identity, &data_frames, data_flags)? }); diff --git a/kernel/memory_structs/src/lib.rs b/kernel/memory_structs/src/lib.rs index 5bbb520cd7..b2bf6c21a4 100644 --- a/kernel/memory_structs/src/lib.rs +++ b/kernel/memory_structs/src/lib.rs @@ -368,11 +368,14 @@ macro_rules! implement_page_frame_range { #[doc = "A convenience method for creating a new `" $TypeName "` that spans \ all [`" $chunk "`]s from the given [`" $address "`] to an end bound based on the given size."] pub fn [](starting_addr: $address, size_in_bytes: usize) -> $TypeName { - assert!(size_in_bytes > 0); - let start = $chunk::containing_address(starting_addr); - // The end bound is inclusive, hence the -1. Parentheses are needed to avoid overflow. - let end = $chunk::containing_address(starting_addr + (size_in_bytes - 1)); - $TypeName::new(start, end) + if size_in_bytes == 0 { + $TypeName::empty() + } else { + let start = $chunk::containing_address(starting_addr); + // The end bound is inclusive, hence the -1. Parentheses are needed to avoid overflow. + let end = $chunk::containing_address(starting_addr + (size_in_bytes - 1)); + $TypeName::new(start, end) + } } #[doc = "Returns the [`" $address "`] of the starting [`" $chunk "`] in this `" $TypeName "`."] diff --git a/kernel/memory_x86_64/src/lib.rs b/kernel/memory_x86_64/src/lib.rs index 3c6d986625..018d532785 100644 --- a/kernel/memory_x86_64/src/lib.rs +++ b/kernel/memory_x86_64/src/lib.rs @@ -60,7 +60,10 @@ pub struct AggregatedSectionMemoryBounds { /// Each of the these section bounds is aggregated to cover the bounds and sizes of *all* sections /// that share the same page table mapping flags and can thus be logically combined. /// * The list of all individual sections found. -pub fn find_section_memory_bounds(boot_info: &impl BootInformation) -> Result<(AggregatedSectionMemoryBounds, [Option; 32]), &'static str> { +pub fn find_section_memory_bounds(boot_info: &impl BootInformation, translate: F) -> Result<(AggregatedSectionMemoryBounds, [Option; 32]), &'static str> +where + F: Fn(VirtualAddress) -> Option, +{ let mut index = 0; let mut init_start: Option<(VirtualAddress, PhysicalAddress)> = None; let mut init_end: Option<(VirtualAddress, PhysicalAddress)> = None; @@ -91,24 +94,16 @@ pub fn find_section_memory_bounds(boot_info: &impl BootInformation) -> Result<(A debug!("Looking at loaded section {} at {:#X}, size {:#X}", section.name(), section.start(), section.len()); let flags = convert_to_pte_flags(§ion); - // even though the linker stipulates that the kernel sections have a higher-half virtual address, - // they are still loaded at a lower physical address, in which phys_addr = virt_addr - KERNEL_OFFSET. - // thus, we must map the zeroeth kernel section from its low address to a higher-half address, - // and we must map all the other sections from their higher given virtual address to the proper lower phys addr - let mut start_phys_addr = section.start().value(); - if start_phys_addr >= KERNEL_OFFSET { - // true for all sections but the first section (inittext) - start_phys_addr -= KERNEL_OFFSET; - } + let mut start_virt_addr = VirtualAddress::new(section.start().value()) + .ok_or("section had invalid starting virtual address")?; + let start_phys_addr = translate(start_virt_addr) + .ok_or("couldn't translate section's starting virtual address")?; - let mut start_virt_addr = section.start().value(); - if start_virt_addr < KERNEL_OFFSET { + if start_virt_addr.value() < KERNEL_OFFSET { // special case to handle the first section only start_virt_addr += KERNEL_OFFSET; } - let start_phys_addr = PhysicalAddress::new(start_phys_addr).ok_or("section had invalid starting physical address")?; - let start_virt_addr = VirtualAddress::new(start_virt_addr).ok_or("section had invalid ending physical address")?; let end_virt_addr = start_virt_addr + section.len(); let end_phys_addr = start_phys_addr + section.len(); diff --git a/kernel/multicore_bringup/src/lib.rs b/kernel/multicore_bringup/src/lib.rs index bded5bc13d..f3f265e39f 100644 --- a/kernel/multicore_bringup/src/lib.rs +++ b/kernel/multicore_bringup/src/lib.rs @@ -22,6 +22,7 @@ extern crate ap_start; extern crate pause; use core::{ + convert::TryInto, ops::DerefMut, sync::atomic::Ordering, }; @@ -194,6 +195,7 @@ pub fn handle_ap_cores( kernel_mmi_ref: &MmiRef, ap_start_realmode_begin: VirtualAddress, ap_start_realmode_end: VirtualAddress, + ap_gdt: VirtualAddress, max_framebuffer_resolution: Option<(u16, u16)>, ) -> Result { let ap_startup_size_in_bytes = ap_start_realmode_end.value() - ap_start_realmode_begin.value(); @@ -261,6 +263,7 @@ pub fn handle_ap_cores( let (max_width, max_height) = max_framebuffer_resolution.unwrap_or((u16::MAX, u16::MAX)); ap_trampoline_data.ap_max_fb_width.write(max_width); ap_trampoline_data.ap_max_fb_height.write(max_height); + ap_trampoline_data.ap_gdt.write(ap_gdt.value().try_into().map_err(|_| "AP_GDT physical address larger than u32::MAX")?); let acpi_tables = acpi::get_acpi_tables().lock(); let madt = Madt::get(&acpi_tables) @@ -338,7 +341,7 @@ pub fn handle_ap_cores( /// # Important Layout Note /// The order of the members in this struct must exactly match how they are used /// and specified in the AP bootup code (at the top of `defines.asm`). -#[derive(FromBytes)] +#[derive(Debug, FromBytes)] #[repr(C)] struct ApTrampolineData { /// A flag that indicates whether the new AP is ready. @@ -372,6 +375,9 @@ struct ApTrampolineData { /// when changing graphical framebuffer modes in its 16-bit real-mode code. ap_max_fb_height: Volatile, _padding5: [u8; 6], + /// The location of the GDT_AP symbol in physical memory. + ap_gdt: Volatile, + _padding6: [u8; 4], } diff --git a/kernel/nano_core/Cargo.toml b/kernel/nano_core/Cargo.toml index 3a3cab9784..f14aa1382c 100644 --- a/kernel/nano_core/Cargo.toml +++ b/kernel/nano_core/Cargo.toml @@ -60,9 +60,8 @@ path = "../memory_initialization" path = "../boot_info" features = ["multiboot2"] -[dependencies.bootloader_api] -git = "https://github.com/theseus-os/bootloader" -branch = "theseus" +[dependencies.uefi-bootloader-api] +git = "https://github.com/theseus-os/uefi-bootloader" optional = true [build-dependencies] @@ -73,7 +72,7 @@ default = [ "bios" ] ## Build for a system that boots via legacy BIOS (multiboot2). bios = ["boot_info/multiboot2", "vga_buffer/bios", "dep:multiboot2"] ## Build for a system that boots via UEFI. -uefi = ["boot_info/uefi", "captain/uefi", "dep:bootloader_api"] +uefi = ["boot_info/uefi", "captain/uefi", "dep:uefi-bootloader-api"] [lib] # staticlib is required to build a self-contained, fully-linked .a file diff --git a/kernel/nano_core/src/asm/ap_boot.asm b/kernel/nano_core/src/asm/ap_boot.asm index 8a99ec7866..b75ccfb7ea 100644 --- a/kernel/nano_core/src/asm/ap_boot.asm +++ b/kernel/nano_core/src/asm/ap_boot.asm @@ -34,8 +34,16 @@ ap_start_protected_mode: %endif ; BIOS ; Load the 64-bit GDT - lgdt [GDT_AP.ptr_low - KERNEL_OFFSET] + mov eax, [AP_GDT] + add eax, GDT_AP.ptr_low - GDT_AP + + ; eax now points to GDT_AP.ptr_low + mov ebx, [AP_GDT] + ; the size ([eax]) is already correct, we just need to set the offset + mov dword [eax + 2], ebx + + lgdt [eax] %ifdef BIOS ; prints GDT @@ -205,6 +213,7 @@ start_high_ap: ; However, during the ap boot phase on real hardware, there is a write page fault ; if you put it in rodata (i.e., map it as read-only). section .data.ap +global GDT_AP GDT_AP: dq 0 ; zero entry .code equ $ - GDT_AP @@ -217,7 +226,8 @@ GDT_AP: ; dw 0 ; padding to make sure GDT pointer is 4-byte aligned .ptr_low: dw .end - GDT_AP - 1 - dd GDT_AP - KERNEL_OFFSET + ; this is overwritten in ap_start_protected_mode to point to the virtual identity address of GDT_AP + dd 0 ; dq GDT_AP - KERNEL_OFFSET .ptr: dw .end - GDT_AP - 1 diff --git a/kernel/nano_core/src/asm/ap_realmode.asm b/kernel/nano_core/src/asm/ap_realmode.asm index d6056eaf0c..926a2300d6 100644 --- a/kernel/nano_core/src/asm/ap_realmode.asm +++ b/kernel/nano_core/src/asm/ap_realmode.asm @@ -400,8 +400,7 @@ prot_mode: mov dword [0xb8010], 0x4f544f43 ; "CT" mov dword [0xb8014], 0x4f444f45 ; "ED" %endif ; BIOS - - + jmp 0x08:ap_start_protected_mode diff --git a/kernel/nano_core/src/asm/defines.asm b/kernel/nano_core/src/asm/defines.asm index ca568d39b1..d1dc0e4dbc 100644 --- a/kernel/nano_core/src/asm/defines.asm +++ b/kernel/nano_core/src/asm/defines.asm @@ -16,6 +16,7 @@ AP_NMI_LINT equ TRAMPOLINE + 56 AP_NMI_FLAGS equ TRAMPOLINE + 64 AP_MAX_FB_WIDTH equ TRAMPOLINE + 72 AP_MAX_FB_HEIGHT equ TRAMPOLINE + 80 +AP_GDT equ TRAMPOLINE + 88 ; Kernel is linked to run at -2Gb KERNEL_OFFSET equ 0xFFFFFFFF80000000 diff --git a/kernel/nano_core/src/lib.rs b/kernel/nano_core/src/lib.rs index a248274db7..dfd8e011c4 100644 --- a/kernel/nano_core/src/lib.rs +++ b/kernel/nano_core/src/lib.rs @@ -127,7 +127,7 @@ where // Parse the nano_core crate (the code we're already running) since we need it to load and run applications. println_raw!("nano_core(): parsing nano_core crate, please wait ..."); - let (nano_core_crate_ref, ap_realmode_begin, ap_realmode_end) = match mod_mgmt::parse_nano_core::parse_nano_core( + let (nano_core_crate_ref, ap_realmode_begin, ap_realmode_end, ap_gdt) = match mod_mgmt::parse_nano_core::parse_nano_core( default_namespace, text_mapped_pages.into_inner(), rodata_mapped_pages.into_inner(), @@ -145,8 +145,28 @@ where .get("ap_start_realmode_end") .and_then(|v| VirtualAddress::new(*v + KERNEL_OFFSET)) .ok_or("Missing/invalid symbol expected from assembly code \"ap_start_realmode_end\"")?; + + let ap_gdt = { + let mut ap_gdt_virtual_address = None; + for (_, section) in nano_core_crate_ref.lock_as_ref().sections.iter() { + if section.name == "GDT_AP".into() { + ap_gdt_virtual_address = Some(section.virt_addr); + break; + } + } + + // The identity-mapped virtual address of GDT_AP. + VirtualAddress::new( + memory::translate(ap_gdt_virtual_address.ok_or( + "Missing/invalid symbol expected from data section \"GDT_AP\"", + )?) + .ok_or("Failed to translate \"GDT_AP\"")? + .value(), + ) + .ok_or("couldn't convert \"GDT_AP\" physical address to virtual")? + }; // debug!("ap_realmode_begin: {:#X}, ap_realmode_end: {:#X}", ap_realmode_begin, ap_realmode_end); - (nano_core_crate_ref, ap_realmode_begin, ap_realmode_end) + (nano_core_crate_ref, ap_realmode_begin, ap_realmode_end, ap_gdt) } Err((msg, mapped_pages_array)) => { // Because this function takes ownership of the text/rodata/data mapped_pages that cover the currently-running code, @@ -181,7 +201,7 @@ where // That's it, the nano_core is done! That's really all it does! println_raw!("nano_core(): invoking the captain..."); #[cfg(not(loadable))] { - captain::init(kernel_mmi_ref, identity_mapped_pages, stack, ap_realmode_begin, ap_realmode_end, rsdp_address)?; + captain::init(kernel_mmi_ref, identity_mapped_pages, stack, ap_realmode_begin, ap_realmode_end, ap_gdt, rsdp_address)?; } #[cfg(loadable)] { use memory::{EarlyIdentityMappedPages, MmiRef, PhysicalAddress}; @@ -194,10 +214,10 @@ where .ok_or("no single symbol matching \"captain::init\"")?; log::info!("The nano_core (in loadable mode) is invoking the captain init function: {:?}", section.name); - type CaptainInitFunc = fn(MmiRef, NoDrop, NoDrop, VirtualAddress, VirtualAddress, Option) -> Result<(), &'static str>; + type CaptainInitFunc = fn(MmiRef, NoDrop, NoDrop, VirtualAddress, VirtualAddress, VirtualAddress, Option) -> Result<(), &'static str>; let func: &CaptainInitFunc = unsafe { section.as_func() }?; - func(kernel_mmi_ref, identity_mapped_pages, stack, ap_realmode_begin, ap_realmode_end, rsdp_address)?; + func(kernel_mmi_ref, identity_mapped_pages, stack, ap_realmode_begin, ap_realmode_end, ap_gdt, rsdp_address)?; } // the captain shouldn't return ... diff --git a/kernel/nano_core/src/uefi.rs b/kernel/nano_core/src/uefi.rs index e315f4c21e..a96eae77d7 100644 --- a/kernel/nano_core/src/uefi.rs +++ b/kernel/nano_core/src/uefi.rs @@ -1,26 +1,15 @@ use crate::{early_setup, nano_core, try_exit}; use boot_info::uefi::STACK_SIZE; -use bootloader_api::{config::Mapping, BootloaderConfig}; use core::arch::asm; use memory::VirtualAddress; +use uefi_bootloader_api::BootInformation; -#[used] -#[link_section = ".bootloader-config"] -pub static __BOOTLOADER_CONFIG: [u8; BootloaderConfig::SERIALIZED_LEN] = { - let mut config = BootloaderConfig::new_default(); - config.mappings.physical_memory = Some(Mapping::Dynamic); - config.mappings.page_table_recursive = - Some(Mapping::FixedAddress(0o177777_776_000_000_000_0000)); - config.kernel_stack_size = STACK_SIZE as u64; - config.serialize() -}; - -/// This is effectively a trampoline function that sets up the proper +/// This is effectively a trampoline function that sets up the proper /// argument values in the proper registers before calling `rust_entry`. #[naked] #[no_mangle] #[link_section = ".init.text"] -pub extern "C" fn _start(boot_info: &'static bootloader_api::BootInfo) { +pub extern "C" fn _start(boot_info: &'static BootInformation) { unsafe { asm!( // Upon entering this function: @@ -33,18 +22,18 @@ pub extern "C" fn _start(boot_info: &'static bootloader_api::BootInfo) { // ^ ^ ^ // | | rsi // kernel_stack_start rsp (top of stack) - // + // // The guard page and double fault stack are both one page in size; // the kernel stack is `KERNEL_STACK_SIZE_IN_PAGES` pages. // // Stacks grow downwards on x86, meaning that the stack pointer will grow // towards the guard page. That's why we start it at the top (the highest vaddr). - + // Before invoking `rust_entry`, we need to set up: // 1. First arg (in rdi): a reference to the boot info (just pass it through). // 2. Second arg (in rsi): the top vaddr of the double fault handler stack. "mov rsi, rsp", // Handle #2 above - + // Now, adjust the stack pointer to the page before the double fault stack, // which is the top of the initial kernel stack that was allocated for us. "sub rsp, 4096", @@ -58,10 +47,7 @@ pub extern "C" fn _start(boot_info: &'static bootloader_api::BootInfo) { }; } -fn rust_entry( - boot_info: &'static bootloader_api::BootInfo, - double_fault_stack: usize, -) { +fn rust_entry(boot_info: &'static BootInformation, double_fault_stack: usize) { try_exit!(early_setup(double_fault_stack)); // See the above diagram in `_start`. let kernel_stack_start = VirtualAddress::new_canonical(double_fault_stack - STACK_SIZE); diff --git a/tools/README.md b/tools/README.md index 016d59ead2..36e050ae52 100644 --- a/tools/README.md +++ b/tools/README.md @@ -11,6 +11,7 @@ This directory contains tools used in Theseus's build process or for testing pur * `serialize_nano_core`: A Rust program that creates a serialized representation of the symbols in the `nano_core` binary from the output of `demangle_readelf_file`. * `grub_cfg_generation`: a Rust program that autogenerates a multiboot2-compliant grub.cfg file for GRUB, specifying which multiboot2 modules should be included in the ISO. * `theseus_cargo`: a wrapper around cargo that supports out-of-tree builds for arbitrary crates that are cross-compiled against an existing build of Theseus. In the future, it will also perform special "partially-static" linking procedures. +* `uefi_builder`: A (collection of) Rust program(s) that generates the necessary files to boot Theseus using UEFI. See `uefi_builder/README.md` for more details on why each target requires its own program. ## Other tools * `diff_crates`: a Rust program that identifies the differences in crate object files across two different Theseus builds, for purposes of creating a live evolution manifest. diff --git a/tools/uefi_builder/Cargo.toml b/tools/uefi_builder/Cargo.toml deleted file mode 100644 index e968051877..0000000000 --- a/tools/uefi_builder/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -# if you encounter: -# `error: no matching package named `bootloader` found` -# compile with -Z bindeps - -[package] -name = "uefi_builder" -version = "0.1.0" -edition = "2021" -authors = ["Klim Tsoutsman "] - -[dependencies] -bootloader = { git = "https://github.com/theseus-os/bootloader", branch = "theseus" } -clap = { version = "4.0", features = ["derive"] } -ovmf-prebuilt = "0.1.0-alpha.1" diff --git a/tools/uefi_builder/README.md b/tools/uefi_builder/README.md new file mode 100644 index 0000000000..1db8075cc9 --- /dev/null +++ b/tools/uefi_builder/README.md @@ -0,0 +1,10 @@ +Using different crates for different targets is necessary until [rust-lang/ +cargo/10030][1] is implemented. + +If you encounter: +``` +error: no matching package named `bootloader` found +```` +Try compiling with `-Z bindeps`. + +[1]: https://github.com/rust-lang/cargo/issues/10030 diff --git a/tools/uefi_builder/aarch64/Cargo.lock b/tools/uefi_builder/aarch64/Cargo.lock new file mode 100644 index 0000000000..a58fe5ec83 --- /dev/null +++ b/tools/uefi_builder/aarch64/Cargo.lock @@ -0,0 +1,961 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anyhow" +version = "1.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bit_field" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "build_const" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ae4235e6dac0694637c763029ecea1a2ec9e4e06ec2729bd21ba4d9c863eb7" + +[[package]] +name = "bumpalo" +version = "3.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "cc" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-integer", + "num-traits", + "time", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "clap" +version = "4.0.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7db700bc935f9e43e88d00b0850dae18a63773cfbec6d8e070fccf7fef89a39" +dependencies = [ + "bitflags", + "clap_derive", + "clap_lex", + "is-terminal", + "once_cell", + "strsim", + "termcolor", +] + +[[package]] +name = "clap_derive" +version = "4.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "cortex-a" +version = "8.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8256fd5103e10027467cc7a97c9ff27fcc4547ea24864da0aff2e7aef6e18e28" +dependencies = [ + "tock-registers", +] + +[[package]] +name = "crc" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" +dependencies = [ + "build_const", +] + +[[package]] +name = "cxx" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5add3fc1717409d029b20c5b6903fc0c0b02fa6741d820054f4a2efa5e5816fd" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c87959ba14bc6fbc61df77c3fcfe180fc32b93538c4f1031dd802ccb5f2ff0" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69a3e162fde4e594ed2b07d0f83c6c67b745e7f28ce58c6df5e6b6bef99dfb59" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e7e2adeb6a0d4a282e581096b06e1791532b7d576dcde5ccd9382acf55db8e6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn", +] + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "fastrand" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", +] + +[[package]] +name = "fatfs" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e18f80a87439240dac45d927fd8f8081b6f1e34c03e97271189fa8a8c2e96c8f" +dependencies = [ + "bitflags", + "byteorder", + "chrono", + "log", +] + +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "goblin" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "572564d6cba7d09775202c8e7eebc4d534d5ae36578ab402fb21e182a0ac9505" +dependencies = [ + "plain", + "scroll", +] + +[[package]] +name = "gpt" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dd7365d734a70ac5dd7be791b0c96083852188df015b8c665bb2dadb108a743" +dependencies = [ + "bitflags", + "crc", + "log", + "uuid", +] + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "is-terminal" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" +dependencies = [ + "hermit-abi", + "io-lifetimes", + "rustix", + "windows-sys", +] + +[[package]] +name = "js-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.139" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" + +[[package]] +name = "link-cplusplus" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" +dependencies = [ + "cc", +] + +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "noto-sans-mono-bitmap" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a27daf9557165efe1d09b52f97393bf6283cadb0a76fbe64a1061e15553a994a" + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" + +[[package]] +name = "os_str_bytes" +version = "6.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" + +[[package]] +name = "ovmf-prebuilt" +version = "0.1.0-alpha.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa50141d081512ab30fd9e7e7692476866df5098b028536ad6680212e717fa8d" + +[[package]] +name = "paste" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" + +[[package]] +name = "plain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "ptr_meta" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcada80daa06c42ed5f48c9a043865edea5dc44cbf9ac009fda3b89526e28607" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bca9224df2e20e7c5548aeb5f110a0f3b77ef05f8585139b7148b59056168ed2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "quote" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "0.36.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4feacf7db682c6c329c4ede12649cd36ecab0f3be5b7d74e6a20304725db4549" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "rustversion" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "scratch" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" + +[[package]] +name = "scroll" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04c565b551bafbef4157586fa379538366e4385d42082f255bfd96e4fe8519da" + +[[package]] +name = "semver" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" + +[[package]] +name = "spin" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6002a767bff9e83f8eeecf883ecb8011875a21ae8da43bffb817a57e78cc09" +dependencies = [ + "lock_api", +] + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "syn" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tempfile" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +dependencies = [ + "cfg-if", + "fastrand", + "libc", + "redox_syscall", + "remove_dir_all", + "winapi", +] + +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "time" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" +dependencies = [ + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi", +] + +[[package]] +name = "tock-registers" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "696941a0aee7e276a165a978b37918fd5d22c55c3d6bda197813070ca9c0f21c" + +[[package]] +name = "ucs2" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bad643914094137d475641b6bab89462505316ec2ce70907ad20102d28a79ab8" +dependencies = [ + "bit_field", +] + +[[package]] +name = "uefi" +version = "0.18.0" +source = "git+https://github.com/rust-osdev/uefi-rs#e8e0429f652b440a63941c4754a51be668f58ebc" +dependencies = [ + "bitflags", + "log", + "ptr_meta", + "ucs2", + "uefi-macros", +] + +[[package]] +name = "uefi-bootloader" +version = "0.1.0" +source = "git+https://github.com/theseus-os/uefi-bootloader#1aeb6f29bf2f3cc2cd2ab2dee893bef5caa1f96c" +dependencies = [ + "bit_field", + "cfg-if", + "cortex-a", + "derive_more", + "goblin", + "log", + "noto-sans-mono-bitmap", + "paste", + "plain", + "spin", + "tock-registers", + "uefi", + "uefi-bootloader-api", + "x86_64", + "zerocopy", +] + +[[package]] +name = "uefi-bootloader-api" +version = "0.1.0" +source = "git+https://github.com/theseus-os/uefi-bootloader#1aeb6f29bf2f3cc2cd2ab2dee893bef5caa1f96c" + +[[package]] +name = "uefi-macros" +version = "0.9.0" +source = "git+https://github.com/rust-osdev/uefi-rs#e8e0429f652b440a63941c4754a51be668f58ebc" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "uefi_builder_aarch64" +version = "0.1.0" +dependencies = [ + "uefi-bootloader", + "uefi_builder_common", +] + +[[package]] +name = "uefi_builder_common" +version = "0.1.0" +dependencies = [ + "anyhow", + "clap", + "fatfs", + "gpt", + "ovmf-prebuilt", + "tempfile", +] + +[[package]] +name = "unicode-ident" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +dependencies = [ + "getrandom", +] + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "volatile" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ca98349dda8a60ae74e04fd90c7fb4d6a4fbe01e6d3be095478aa0b76f6c0c" + +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" + +[[package]] +name = "x86_64" +version = "0.14.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "100555a863c0092238c2e0e814c1096c1e5cf066a309c696a87e907b5f8c5d69" +dependencies = [ + "bit_field", + "bitflags", + "rustversion", + "volatile", +] + +[[package]] +name = "zerocopy" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "332f188cc1bcf1fe1064b8c58d150f497e697f49774aa846f2dc949d9a25f236" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6505e6815af7de1746a08f69c69606bb45695a17149517680f3b2149713b19a3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/tools/uefi_builder/aarch64/Cargo.toml b/tools/uefi_builder/aarch64/Cargo.toml new file mode 100644 index 0000000000..82e350b0fd --- /dev/null +++ b/tools/uefi_builder/aarch64/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "uefi_builder_aarch64" +version = "0.1.0" +authors = ["Klim Tsoutsman "] +description = "Creates the files necessary to boot Theseus using UEFI on aarch64" +edition = "2021" + +[dependencies] +uefi_builder_common = { path = "../common" } + +[dependencies.uefi-bootloader] +artifact = "bin" +git = "https://github.com/theseus-os/uefi-bootloader" +target = "aarch64-unknown-uefi" + +[patch.crates-io] +uefi-macros = { git = "https://github.com/rust-osdev/uefi-rs" } diff --git a/tools/uefi_builder/aarch64/src/main.rs b/tools/uefi_builder/aarch64/src/main.rs new file mode 100644 index 0000000000..5de4d9f3ba --- /dev/null +++ b/tools/uefi_builder/aarch64/src/main.rs @@ -0,0 +1,8 @@ +use std::path::Path; + +fn main() { + uefi_builder_common::main( + Path::new(env!("CARGO_BIN_FILE_UEFI_BOOTLOADER")), + Path::new("efi/boot/bootaa64.efi"), + ); +} diff --git a/tools/uefi_builder/Cargo.lock b/tools/uefi_builder/common/Cargo.lock similarity index 77% rename from tools/uefi_builder/Cargo.lock rename to tools/uefi_builder/common/Cargo.lock index f59ec15d4e..4bff603e8b 100644 --- a/tools/uefi_builder/Cargo.lock +++ b/tools/uefi_builder/common/Cargo.lock @@ -13,9 +13,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.66" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" +checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" [[package]] name = "autocfg" @@ -23,46 +23,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] - [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - -[[package]] -name = "bootloader" -version = "0.11.0" -source = "git+https://github.com/theseus-os/bootloader?branch=theseus#6cc130e2f9dc633445846a1e2c4d961b1daddd78" -dependencies = [ - "anyhow", - "fatfs", - "gpt", - "llvm-tools", - "mbrman", - "tempfile", -] - [[package]] name = "build_const" version = "0.2.2" @@ -83,9 +49,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cc" -version = "1.0.77" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" +checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" [[package]] name = "cfg-if" @@ -110,9 +76,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.29" +version = "4.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d63b9e9c07271b9957ad22c173bae2a4d9a81127680962039296abcd2f8251d" +checksum = "a7db700bc935f9e43e88d00b0850dae18a63773cfbec6d8e070fccf7fef89a39" dependencies = [ "bitflags", "clap_derive", @@ -172,9 +138,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.82" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4a41a86530d0fe7f5d9ea779916b7cadd2d4f9add748b99c2c029cbbdfaf453" +checksum = "5add3fc1717409d029b20c5b6903fc0c0b02fa6741d820054f4a2efa5e5816fd" dependencies = [ "cc", "cxxbridge-flags", @@ -184,9 +150,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.82" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06416d667ff3e3ad2df1cd8cd8afae5da26cf9cec4d0825040f88b5ca659a2f0" +checksum = "b4c87959ba14bc6fbc61df77c3fcfe180fc32b93538c4f1031dd802ccb5f2ff0" dependencies = [ "cc", "codespan-reporting", @@ -199,15 +165,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.82" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "820a9a2af1669deeef27cb271f476ffd196a2c4b6731336011e0ba63e2c7cf71" +checksum = "69a3e162fde4e594ed2b07d0f83c6c67b745e7f28ce58c6df5e6b6bef99dfb59" [[package]] name = "cxxbridge-macro" -version = "1.0.82" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08a6e2fcc370a089ad3b4aaf54db3b1b4cee38ddabce5896b33eb693275f470" +checksum = "3e7e2adeb6a0d4a282e581096b06e1791532b7d576dcde5ccd9382acf55db8e6" dependencies = [ "proc-macro2", "quote", @@ -256,12 +222,6 @@ dependencies = [ "log", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "getrandom" version = "0.2.8" @@ -345,9 +305,9 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927609f78c2913a6f6ac3c27a4fe87f43e2a35367c0c4b0f8265e8f49a104330" +checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" dependencies = [ "hermit-abi", "io-lifetimes", @@ -366,15 +326,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.137" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "link-cplusplus" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" dependencies = [ "cc", ] @@ -385,12 +345,6 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" -[[package]] -name = "llvm-tools" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955be5d0ca0465caf127165acb47964f911e2bc26073e865deb8be7189302faf" - [[package]] name = "log" version = "0.4.17" @@ -400,19 +354,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "mbrman" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4b239f4755d00466e3ac1d55ddeaf77a66c7580352fc6cbc40d56c218fc94a9" -dependencies = [ - "bincode", - "bitvec", - "serde", - "serde-big-array", - "thiserror", -] - [[package]] name = "num-integer" version = "0.1.45" @@ -434,9 +375,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" +checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" [[package]] name = "os_str_bytes" @@ -476,28 +417,22 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.47" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.21" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "redox_syscall" version = "0.2.16" @@ -518,9 +453,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.5" +version = "0.36.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3807b5d10909833d3e9acd1eb5fb988f79376ff10fce42937de71a449c4c588" +checksum = "4feacf7db682c6c329c4ede12649cd36ecab0f3be5b7d74e6a20304725db4549" dependencies = [ "bitflags", "errno", @@ -532,38 +467,9 @@ dependencies = [ [[package]] name = "scratch" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" - -[[package]] -name = "serde" -version = "1.0.147" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde-big-array" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3323f09a748af288c3dc2474ea6803ee81f118321775bffa3ac8f7e65c5e90e7" -dependencies = [ - "serde", -] - -[[package]] -name = "serde_derive" -version = "1.0.147" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] +checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" [[package]] name = "strsim" @@ -573,21 +479,15 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.103" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - [[package]] name = "tempfile" version = "3.3.0" @@ -611,31 +511,11 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "thiserror" -version = "1.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "time" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" dependencies = [ "libc", "wasi 0.10.0+wasi-snapshot-preview1", @@ -643,19 +523,22 @@ dependencies = [ ] [[package]] -name = "uefi_builder" +name = "uefi_builder_common" version = "0.1.0" dependencies = [ - "bootloader", + "anyhow", "clap", + "fatfs", + "gpt", "ovmf-prebuilt", + "tempfile", ] [[package]] name = "unicode-ident" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" [[package]] name = "unicode-width" @@ -831,12 +714,3 @@ name = "windows_x86_64_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] diff --git a/tools/uefi_builder/common/Cargo.toml b/tools/uefi_builder/common/Cargo.toml new file mode 100644 index 0000000000..03a1736d6c --- /dev/null +++ b/tools/uefi_builder/common/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "uefi_builder_common" +version = "0.1.0" +authors = ["Klim Tsoutsman "] +descriptions = "Architecture-agnostic functionality for creating UEFI-compatible boot images" +edition = "2021" + +[dependencies] +anyhow = "1.0" +clap = { version = "4.0", features = ["derive"] } +fatfs = "0.3" +gpt = "3.0" +ovmf-prebuilt = "0.1.0-alpha.1" +tempfile = "3.3" diff --git a/tools/uefi_builder/common/src/fs.rs b/tools/uefi_builder/common/src/fs.rs new file mode 100644 index 0000000000..ffc31c9c9d --- /dev/null +++ b/tools/uefi_builder/common/src/fs.rs @@ -0,0 +1,214 @@ +//! Taken from rust-osdev/bootloader + +use anyhow::Context; +use std::{ + collections::BTreeMap, + fs::{self, File}, + io::{self, Seek}, + path::{Path, PathBuf}, +}; +use tempfile::NamedTempFile; + +/// Create disk images for booting on UEFI systems. +pub struct UefiBoot { + kernel: PathBuf, + extra_files: Vec<(PathBuf, PathBuf)>, +} + +impl UefiBoot { + /// Start creating a disk image for the given bootloader ELF executable. + pub fn new(kernel_path: &Path) -> Self { + Self { + kernel: kernel_path.to_owned(), + extra_files: Vec::new(), + } + } + + /// Create a bootable BIOS disk image at the given path. + pub fn create_disk_image( + &self, + bootloader_host_path: &Path, + bootloader_efi_path: &Path, + out_path: &Path, + ) -> anyhow::Result<()> { + let fat_partition = self + .create_fat_partition(bootloader_efi_path, bootloader_host_path) + .context("failed to create FAT partition")?; + + create_gpt_disk(fat_partition.path(), out_path) + .context("failed to create UEFI GPT disk image")?; + + fat_partition + .close() + .context("failed to delete FAT partition after disk image creation")?; + + Ok(()) + } + + /// Adds a file to the disk image. + pub fn add_file(&mut self, image_path: PathBuf, host_path: PathBuf) { + self.extra_files.push((image_path, host_path)); + } + + /// Creates an UEFI-bootable FAT partition with the kernel. + fn create_fat_partition( + &self, + bootloader_efi_path: &Path, + bootloader_host_path: &Path, + ) -> anyhow::Result { + let mut files = BTreeMap::new(); + files.insert(bootloader_efi_path, bootloader_host_path); + files.insert(Path::new("kernel.elf"), self.kernel.as_path()); + + for (image_path, host_path) in &self.extra_files { + files.insert(image_path, host_path); + } + + let out_file = NamedTempFile::new().context("failed to create temp file")?; + create_fat_filesystem(files, out_file.path()) + .context("failed to create UEFI FAT filesystem")?; + + Ok(out_file) + } +} + +pub fn create_gpt_disk(fat_image: &Path, out_gpt_path: &Path) -> anyhow::Result<()> { + // create new file + let mut disk = fs::OpenOptions::new() + .create(true) + .truncate(true) + .read(true) + .write(true) + .open(out_gpt_path) + .with_context(|| format!("failed to create GPT file at `{}`", out_gpt_path.display()))?; + + // set file size + let partition_size: u64 = fs::metadata(fat_image) + .context("failed to read metadata of fat image")? + .len(); + let disk_size = partition_size + 1024 * 64; // for GPT headers + disk.set_len(disk_size) + .context("failed to set GPT image file length")?; + + // create a protective MBR at LBA0 so that disk is not considered + // unformatted on BIOS systems + let mbr = gpt::mbr::ProtectiveMBR::with_lb_size( + u32::try_from((disk_size / 512) - 1).unwrap_or(0xFF_FF_FF_FF), + ); + mbr.overwrite_lba0(&mut disk) + .context("failed to write protective MBR")?; + + // create new GPT structure + let block_size = gpt::disk::LogicalBlockSize::Lb512; + let mut gpt = gpt::GptConfig::new() + .writable(true) + .initialized(false) + .logical_block_size(block_size) + .create_from_device(Box::new(&mut disk), None) + .context("failed to create GPT structure in file")?; + gpt.update_partitions(Default::default()) + .context("failed to update GPT partitions")?; + + // add new EFI system partition and get its byte offset in the file + let partition_id = gpt + .add_partition("boot", partition_size, gpt::partition_types::EFI, 0, None) + .context("failed to add boot EFI partition")?; + let partition = gpt + .partitions() + .get(&partition_id) + .context("failed to open boot partition after creation")?; + let start_offset = partition + .bytes_start(block_size) + .context("failed to get start offset of boot partition")?; + + // close the GPT structure and write out changes + gpt.write().context("failed to write out GPT changes")?; + + // place the FAT filesystem in the newly created partition + disk.seek(io::SeekFrom::Start(start_offset)) + .context("failed to seek to start offset")?; + io::copy( + &mut File::open(fat_image).context("failed to open FAT image")?, + &mut disk, + ) + .context("failed to copy FAT image to GPT disk")?; + + Ok(()) +} + +pub fn create_fat_filesystem( + files: BTreeMap<&Path, &Path>, + out_fat_path: &Path, +) -> anyhow::Result<()> { + const MB: u64 = 1024 * 1024; + + // calculate needed size + let mut needed_size = 0; + for path in files.values() { + let file_size = fs::metadata(path) + .with_context(|| format!("failed to read metadata of file `{}`", path.display()))? + .len(); + needed_size += file_size; + } + + // create new filesystem image file at the given path and set its length + let fat_file = fs::OpenOptions::new() + .read(true) + .write(true) + .create(true) + .truncate(true) + .open(out_fat_path) + .unwrap(); + let fat_size_padded_and_rounded = ((needed_size + 1024 * 64 - 1) / MB + 1) * MB; + fat_file.set_len(fat_size_padded_and_rounded).unwrap(); + + // choose a file system label + let mut label = *b"MY_RUST_OS!"; + if let Some(path) = files.get(Path::new("kernel.elf")) { + if let Some(name) = path.file_stem() { + let converted = name.to_string_lossy(); + let name = converted.as_bytes(); + let mut new_label = [0u8; 11]; + let name = &name[..usize::min(new_label.len(), name.len())]; + let slice = &mut new_label[..name.len()]; + slice.copy_from_slice(name); + label = new_label; + } + } + + // format the file system and open it + let format_options = fatfs::FormatVolumeOptions::new().volume_label(label); + fatfs::format_volume(&fat_file, format_options).context("Failed to format FAT file")?; + let filesystem = fatfs::FileSystem::new(&fat_file, fatfs::FsOptions::new()) + .context("Failed to open FAT file system of UEFI FAT file")?; + + // copy files to file system + let root_dir = filesystem.root_dir(); + for (target_path, file_path) in files { + // create parent directories + let ancestors: Vec<_> = target_path.ancestors().skip(1).collect(); + for ancestor in ancestors.into_iter().rev().skip(1) { + root_dir + .create_dir(&ancestor.display().to_string()) + .with_context(|| { + format!( + "failed to create directory `{}` on FAT filesystem", + ancestor.display() + ) + })?; + } + + let mut new_file = root_dir + .create_file(target_path.to_str().unwrap()) + .with_context(|| format!("failed to create file at `{}`", target_path.display()))?; + new_file.truncate().unwrap(); + io::copy( + &mut fs::File::open(file_path) + .with_context(|| format!("failed to open `{}` for copying", file_path.display()))?, + &mut new_file, + ) + .with_context(|| format!("failed to copy `{}` to FAT filesystem", file_path.display()))?; + } + + Ok(()) +} diff --git a/tools/uefi_builder/common/src/lib.rs b/tools/uefi_builder/common/src/lib.rs new file mode 100644 index 0000000000..da1b72ee46 --- /dev/null +++ b/tools/uefi_builder/common/src/lib.rs @@ -0,0 +1,62 @@ +mod fs; + +use clap::Parser; +use fs::UefiBoot; +use std::path::{Path, PathBuf}; + +#[derive(Parser)] +struct Args { + /// Path to the kernel image. + #[arg(long)] + kernel: PathBuf, + /// Path to the modules directory. + #[arg(long)] + modules: Option, + /// Path at which the EFI image should be placed. + #[arg(long)] + efi_image: PathBuf, + /// Path at which the EFI firmware should be placed. + #[arg(long)] + efi_firmware: Option, +} + +pub fn main(bootloader_host_path: &Path, bootloader_efi_path: &Path) { + let Args { + kernel, + modules, + efi_image, + efi_firmware, + } = Args::parse(); + + let mut bootloader = UefiBoot::new(&kernel); + + if let Some(modules) = modules { + for file in modules + .read_dir() + .expect("failed to open modules directory") + { + let file = file.expect("failed to read file"); + if file.file_type().expect("couldn't get file type").is_file() { + bootloader.add_file( + format!( + "modules/{}", + file.file_name() + .to_str() + .expect("couldn't convert path to str") + ) + .into(), + file.path(), + ); + } + } + } + + bootloader + .create_disk_image(bootloader_host_path, bootloader_efi_path, &efi_image) + .expect("failed to create uefi disk image"); + + if let Some(efi_firmware) = efi_firmware { + std::fs::copy(ovmf_prebuilt::ovmf_pure_efi(), efi_firmware) + .expect("couldn't copy efi firmware"); + } +} diff --git a/tools/uefi_builder/src/main.rs b/tools/uefi_builder/src/main.rs deleted file mode 100644 index 9aaffd56f7..0000000000 --- a/tools/uefi_builder/src/main.rs +++ /dev/null @@ -1,55 +0,0 @@ -use clap::Parser; -use std::path::PathBuf; - -#[derive(Parser)] -struct Args { - /// Path to the kernel image. - #[arg(long)] - kernel: PathBuf, - /// Path to the modules directory. - #[arg(long)] - modules: PathBuf, - /// Path at which the EFI image should be placed. - #[arg(long)] - efi_image: PathBuf, - /// Path at which the EFI firmware should be placed. - #[arg(long)] - efi_firmware: PathBuf, -} - -fn main() { - let Args { - kernel, - modules, - efi_image, - efi_firmware, - } = Args::parse(); - - let mut bootloader = bootloader::UefiBoot::new(&kernel); - - for file in modules - .read_dir() - .expect("failed to open modules directory") - { - let file = file.expect("failed to read file"); - if file.file_type().expect("couldn't get file type").is_file() { - bootloader.add_file( - format!( - "modules/{}", - file.file_name() - .to_str() - .expect("couldn't convert path to str") - ) - .into(), - file.path(), - ); - } - } - - bootloader - .create_disk_image(&efi_image) - .expect("failed to create uefi disk image"); - - std::fs::copy(ovmf_prebuilt::ovmf_pure_efi(), efi_firmware) - .expect("couldn't copy efi firmware"); -} diff --git a/tools/uefi_builder/x86_64/Cargo.lock b/tools/uefi_builder/x86_64/Cargo.lock new file mode 100644 index 0000000000..a1888d957b --- /dev/null +++ b/tools/uefi_builder/x86_64/Cargo.lock @@ -0,0 +1,961 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anyhow" +version = "1.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bit_field" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "build_const" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ae4235e6dac0694637c763029ecea1a2ec9e4e06ec2729bd21ba4d9c863eb7" + +[[package]] +name = "bumpalo" +version = "3.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "cc" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-integer", + "num-traits", + "time", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "clap" +version = "4.0.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7db700bc935f9e43e88d00b0850dae18a63773cfbec6d8e070fccf7fef89a39" +dependencies = [ + "bitflags", + "clap_derive", + "clap_lex", + "is-terminal", + "once_cell", + "strsim", + "termcolor", +] + +[[package]] +name = "clap_derive" +version = "4.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "cortex-a" +version = "8.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8256fd5103e10027467cc7a97c9ff27fcc4547ea24864da0aff2e7aef6e18e28" +dependencies = [ + "tock-registers", +] + +[[package]] +name = "crc" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" +dependencies = [ + "build_const", +] + +[[package]] +name = "cxx" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5add3fc1717409d029b20c5b6903fc0c0b02fa6741d820054f4a2efa5e5816fd" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c87959ba14bc6fbc61df77c3fcfe180fc32b93538c4f1031dd802ccb5f2ff0" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69a3e162fde4e594ed2b07d0f83c6c67b745e7f28ce58c6df5e6b6bef99dfb59" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e7e2adeb6a0d4a282e581096b06e1791532b7d576dcde5ccd9382acf55db8e6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn", +] + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "fastrand" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", +] + +[[package]] +name = "fatfs" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e18f80a87439240dac45d927fd8f8081b6f1e34c03e97271189fa8a8c2e96c8f" +dependencies = [ + "bitflags", + "byteorder", + "chrono", + "log", +] + +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "goblin" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "572564d6cba7d09775202c8e7eebc4d534d5ae36578ab402fb21e182a0ac9505" +dependencies = [ + "plain", + "scroll", +] + +[[package]] +name = "gpt" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dd7365d734a70ac5dd7be791b0c96083852188df015b8c665bb2dadb108a743" +dependencies = [ + "bitflags", + "crc", + "log", + "uuid", +] + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "is-terminal" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" +dependencies = [ + "hermit-abi", + "io-lifetimes", + "rustix", + "windows-sys", +] + +[[package]] +name = "js-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.139" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" + +[[package]] +name = "link-cplusplus" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" +dependencies = [ + "cc", +] + +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "noto-sans-mono-bitmap" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a27daf9557165efe1d09b52f97393bf6283cadb0a76fbe64a1061e15553a994a" + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" + +[[package]] +name = "os_str_bytes" +version = "6.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" + +[[package]] +name = "ovmf-prebuilt" +version = "0.1.0-alpha.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa50141d081512ab30fd9e7e7692476866df5098b028536ad6680212e717fa8d" + +[[package]] +name = "paste" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" + +[[package]] +name = "plain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "ptr_meta" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcada80daa06c42ed5f48c9a043865edea5dc44cbf9ac009fda3b89526e28607" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bca9224df2e20e7c5548aeb5f110a0f3b77ef05f8585139b7148b59056168ed2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "quote" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "0.36.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4feacf7db682c6c329c4ede12649cd36ecab0f3be5b7d74e6a20304725db4549" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "rustversion" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "scratch" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" + +[[package]] +name = "scroll" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04c565b551bafbef4157586fa379538366e4385d42082f255bfd96e4fe8519da" + +[[package]] +name = "semver" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" + +[[package]] +name = "spin" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6002a767bff9e83f8eeecf883ecb8011875a21ae8da43bffb817a57e78cc09" +dependencies = [ + "lock_api", +] + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "syn" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tempfile" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +dependencies = [ + "cfg-if", + "fastrand", + "libc", + "redox_syscall", + "remove_dir_all", + "winapi", +] + +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "time" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" +dependencies = [ + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi", +] + +[[package]] +name = "tock-registers" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "696941a0aee7e276a165a978b37918fd5d22c55c3d6bda197813070ca9c0f21c" + +[[package]] +name = "ucs2" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bad643914094137d475641b6bab89462505316ec2ce70907ad20102d28a79ab8" +dependencies = [ + "bit_field", +] + +[[package]] +name = "uefi" +version = "0.18.0" +source = "git+https://github.com/rust-osdev/uefi-rs#e8e0429f652b440a63941c4754a51be668f58ebc" +dependencies = [ + "bitflags", + "log", + "ptr_meta", + "ucs2", + "uefi-macros", +] + +[[package]] +name = "uefi-bootloader" +version = "0.1.0" +source = "git+https://github.com/theseus-os/uefi-bootloader#1aeb6f29bf2f3cc2cd2ab2dee893bef5caa1f96c" +dependencies = [ + "bit_field", + "cfg-if", + "cortex-a", + "derive_more", + "goblin", + "log", + "noto-sans-mono-bitmap", + "paste", + "plain", + "spin", + "tock-registers", + "uefi", + "uefi-bootloader-api", + "x86_64", + "zerocopy", +] + +[[package]] +name = "uefi-bootloader-api" +version = "0.1.0" +source = "git+https://github.com/theseus-os/uefi-bootloader#1aeb6f29bf2f3cc2cd2ab2dee893bef5caa1f96c" + +[[package]] +name = "uefi-macros" +version = "0.9.0" +source = "git+https://github.com/rust-osdev/uefi-rs#8fe9a92185f38d30eac2688d89ee706cbbf5e4c2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "uefi_builder_common" +version = "0.1.0" +dependencies = [ + "anyhow", + "clap", + "fatfs", + "gpt", + "ovmf-prebuilt", + "tempfile", +] + +[[package]] +name = "uefi_builder_x86_64" +version = "0.1.0" +dependencies = [ + "uefi-bootloader", + "uefi_builder_common", +] + +[[package]] +name = "unicode-ident" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +dependencies = [ + "getrandom", +] + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "volatile" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ca98349dda8a60ae74e04fd90c7fb4d6a4fbe01e6d3be095478aa0b76f6c0c" + +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" + +[[package]] +name = "x86_64" +version = "0.14.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "100555a863c0092238c2e0e814c1096c1e5cf066a309c696a87e907b5f8c5d69" +dependencies = [ + "bit_field", + "bitflags", + "rustversion", + "volatile", +] + +[[package]] +name = "zerocopy" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "332f188cc1bcf1fe1064b8c58d150f497e697f49774aa846f2dc949d9a25f236" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6505e6815af7de1746a08f69c69606bb45695a17149517680f3b2149713b19a3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/tools/uefi_builder/x86_64/Cargo.toml b/tools/uefi_builder/x86_64/Cargo.toml new file mode 100644 index 0000000000..9e3f67d2a1 --- /dev/null +++ b/tools/uefi_builder/x86_64/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "uefi_builder_x86_64" +version = "0.1.0" +authors = ["Klim Tsoutsman "] +description = "Creates the files necessary to boot Theseus using UEFI on x86_64" +edition = "2021" + +[dependencies] +uefi_builder_common = { path = "../common" } + +[dependencies.uefi-bootloader] +artifact = "bin" +git = "https://github.com/theseus-os/uefi-bootloader" +target = "x86_64-unknown-uefi" + +[patch.crates-io] +uefi-macros = { git = "https://github.com/rust-osdev/uefi-rs" } diff --git a/tools/uefi_builder/x86_64/src/main.rs b/tools/uefi_builder/x86_64/src/main.rs new file mode 100644 index 0000000000..d00a88ea7e --- /dev/null +++ b/tools/uefi_builder/x86_64/src/main.rs @@ -0,0 +1,8 @@ +use std::path::Path; + +fn main() { + uefi_builder_common::main( + Path::new(env!("CARGO_BIN_FILE_UEFI_BOOTLOADER")), + Path::new("efi/boot/bootx64.efi"), + ); +}