Skip to content

Commit 0ebdb33

Browse files
committed
chore(format): format all code
1 parent 7fdcdbb commit 0ebdb33

54 files changed

Lines changed: 242 additions & 192 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/0x01/crates/boot/src/allocator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use uefi::boot::{AllocateType, MemoryType};
2-
use x86_64::{structures::paging::*, PhysAddr};
2+
use x86_64::{PhysAddr, structures::paging::*};
33

44
/// Use `BootServices::allocate_pages()` as frame allocator
55
pub struct UEFIFrameAllocator;

src/0x01/crates/boot/src/config.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ pub struct Config<'a> {
99
pub kernel_stack_auto_grow: u64,
1010
/// The size of the kernel stack, given in number of 4KiB pages
1111
pub kernel_stack_size: u64,
12-
/// The offset into the virtual address space where the physical memory is mapped
12+
/// The offset into the virtual address space where the physical memory is
13+
/// mapped
1314
pub physical_memory_offset: u64,
1415
/// The path of kernel ELF
1516
pub kernel_path: &'a str,

src/0x01/crates/boot/src/fs.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use core::ptr::NonNull;
2-
use uefi::boot::*;
3-
use uefi::proto::media::file::*;
4-
use uefi::proto::media::fs::SimpleFileSystem;
2+
3+
use uefi::{
4+
boot::*,
5+
proto::media::{file::*, fs::SimpleFileSystem},
6+
};
57
use xmas_elf::ElfFile;
68

79
/// Open root directory

src/0x01/crates/boot/src/lib.rs

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
#![no_std]
22

3-
pub use uefi::boot::{MemoryAttribute, MemoryDescriptor, MemoryType};
4-
pub use uefi::data_types::chars::*;
5-
pub use uefi::data_types::*;
6-
pub use uefi::proto::console::gop::{GraphicsOutput, ModeInfo};
7-
pub use uefi::Status;
3+
use core::ptr::NonNull;
84

95
use arrayvec::ArrayVec;
10-
use core::ptr::NonNull;
11-
use x86_64::registers::control::Cr3;
12-
use x86_64::structures::paging::{OffsetPageTable, PageTable};
13-
use x86_64::VirtAddr;
6+
pub use uefi::{
7+
Status,
8+
boot::{MemoryAttribute, MemoryDescriptor, MemoryType},
9+
data_types::{chars::*, *},
10+
proto::console::gop::{GraphicsOutput, ModeInfo},
11+
};
12+
use x86_64::{
13+
VirtAddr,
14+
registers::control::Cr3,
15+
structures::paging::{OffsetPageTable, PageTable},
16+
};
1417

1518
pub mod allocator;
1619
pub mod config;
@@ -22,12 +25,14 @@ pub use fs::*;
2225
#[macro_use]
2326
extern crate log;
2427

25-
/// This structure represents the information that the bootloader passes to the kernel.
28+
/// This structure represents the information that the bootloader passes to the
29+
/// kernel.
2630
pub struct BootInfo {
2731
/// The memory map
2832
pub memory_map: ArrayVec<MemoryDescriptor, 256>,
2933

30-
/// The offset into the virtual address space where the physical memory is mapped.
34+
/// The offset into the virtual address space where the physical memory is
35+
/// mapped.
3136
pub physical_memory_offset: u64,
3237

3338
/// The system table virtual address
@@ -49,7 +54,8 @@ static mut ENTRY: usize = 0;
4954
///
5055
/// # Safety
5156
///
52-
/// This function is unsafe because the caller must ensure that the kernel entry point is valid.
57+
/// This function is unsafe because the caller must ensure that the kernel entry
58+
/// point is valid.
5359
#[cfg(feature = "boot")]
5460
pub fn jump_to_entry(bootinfo: *const BootInfo, stacktop: u64) -> ! {
5561
unsafe {
@@ -63,7 +69,8 @@ pub fn jump_to_entry(bootinfo: *const BootInfo, stacktop: u64) -> ! {
6369
///
6470
/// # Safety
6571
///
66-
/// This function is unsafe because the caller must ensure that the kernel entry point is valid.
72+
/// This function is unsafe because the caller must ensure that the kernel entry
73+
/// point is valid.
6774
#[inline(always)]
6875
#[cfg(feature = "boot")]
6976
pub fn set_entry(entry: usize) {
@@ -77,9 +84,10 @@ pub fn set_entry(entry: usize) {
7784
///
7885
/// The function must have the signature `fn(&'static BootInfo) -> !`.
7986
///
80-
/// This macro just creates a function named `_start`, which the linker will use as the entry
81-
/// point. The advantage of using this macro instead of providing an own `_start` function is
82-
/// that the macro ensures that the function and argument types are correct.
87+
/// This macro just creates a function named `_start`, which the linker will use
88+
/// as the entry point. The advantage of using this macro instead of providing
89+
/// an own `_start` function is that the macro ensures that the function and
90+
/// argument types are correct.
8391
#[macro_export]
8492
macro_rules! entry_point {
8593
($path:path) => {

src/0x01/crates/boot/src/main.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
extern crate log;
77
extern crate alloc;
88

9-
use alloc::boxed::Box;
10-
use alloc::vec;
11-
use uefi::{entry, Status};
9+
use alloc::{boxed::Box, vec};
10+
11+
use uefi::{Status, entry};
1212
use x86_64::registers::control::*;
1313
use ysos_boot::*;
1414

@@ -64,7 +64,6 @@ fn efi_main() -> Status {
6464
let ptr = uefi::table::system_table_raw().expect("Failed to get system table");
6565
let system_table = ptr.cast::<core::ffi::c_void>();
6666

67-
6867
// 6. Exit boot and jump to ELF entry
6968
info!("Exiting boot services...");
7069

src/0x01/crates/elf/src/lib.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ extern crate log;
55

66
use core::ptr::{copy_nonoverlapping, write_bytes};
77

8-
use x86_64::structures::paging::page::PageRange;
9-
use x86_64::structures::paging::{mapper::*, *};
10-
use x86_64::{align_up, PhysAddr, VirtAddr};
11-
use xmas_elf::{program, ElfFile};
8+
use x86_64::{
9+
PhysAddr, VirtAddr, align_up,
10+
structures::paging::{mapper::*, page::PageRange, *},
11+
};
12+
use xmas_elf::{ElfFile, program};
1213

1314
/// Map physical memory
1415
///
@@ -95,13 +96,7 @@ pub fn load_elf(
9596
continue;
9697
}
9798

98-
load_segment(
99-
elf,
100-
physical_offset,
101-
&segment,
102-
page_table,
103-
frame_allocator,
104-
)?
99+
load_segment(elf, physical_offset, &segment, page_table, frame_allocator)?
105100
}
106101

107102
Ok(())
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
mod uart16550;
21
pub mod serial;
2+
mod uart16550;

src/0x01/crates/kernel/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ mod drivers;
1616
pub use alloc::format;
1717

1818
use boot::BootInfo;
19-
use uefi::{runtime::ResetType, Status};
19+
use uefi::{Status, runtime::ResetType};
2020

2121
pub fn init(boot_info: &'static BootInfo) {
2222
unsafe {

src/0x01/crates/kernel/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
extern crate log;
66

77
use core::arch::asm;
8+
89
use ysos_kernel as ysos;
910

1011
boot::entry_point!(kernel_main);

src/0x01/crates/kernel/src/utils/macros.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
use alloc::string::ToString;
2-
use crate::drivers::serial::{SERIAL, get_serial};
32
use core::{arch::asm, fmt::*};
3+
44
use x86_64::instructions::interrupts;
55

6+
use crate::drivers::serial::{SERIAL, get_serial};
7+
68
/// Use spin mutex to control variable access
79
#[macro_export]
810
macro_rules! guard_access_fn {
@@ -175,4 +177,3 @@ fn is_canonical(addr: usize) -> bool {
175177
let upper = addr >> 47;
176178
upper == 0 || upper == 0x1ffff
177179
}
178-

0 commit comments

Comments
 (0)