mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-29 04:13:24 +00:00
Format Rust code
This commit is contained in:
1
Makefile
1
Makefile
@ -23,7 +23,6 @@ docs:
|
|||||||
@cd docs && mdbook build # Build mdBook
|
@cd docs && mdbook build # Build mdBook
|
||||||
|
|
||||||
check:
|
check:
|
||||||
@cd src && cargo check # Check dependency errors
|
|
||||||
@cd src && cargo fmt --check # Check Rust format issues
|
@cd src && cargo fmt --check # Check Rust format issues
|
||||||
@cd src && cargo clippy # Check common programming mistakes
|
@cd src && cargo clippy # Check common programming mistakes
|
||||||
|
|
||||||
|
@ -38,11 +38,10 @@ use bootloader::{
|
|||||||
boot_info::{FrameBuffer, MemoryRegionKind},
|
boot_info::{FrameBuffer, MemoryRegionKind},
|
||||||
BootInfo,
|
BootInfo,
|
||||||
};
|
};
|
||||||
use trap::{TrapFrame, IrqLine, IrqCallbackHandle};
|
use trap::{IrqCallbackHandle, IrqLine, TrapFrame};
|
||||||
|
|
||||||
static mut IRQ_CALLBACK_LIST: Vec<IrqCallbackHandle> = Vec::new();
|
static mut IRQ_CALLBACK_LIST: Vec<IrqCallbackHandle> = Vec::new();
|
||||||
|
|
||||||
|
|
||||||
pub fn init(boot_info: &'static mut BootInfo) {
|
pub fn init(boot_info: &'static mut BootInfo) {
|
||||||
let siz = boot_info.framebuffer.as_ref().unwrap() as *const FrameBuffer as usize;
|
let siz = boot_info.framebuffer.as_ref().unwrap() as *const FrameBuffer as usize;
|
||||||
device::init(boot_info.framebuffer.as_mut().unwrap());
|
device::init(boot_info.framebuffer.as_mut().unwrap());
|
||||||
@ -71,8 +70,6 @@ pub fn init(boot_info: &'static mut BootInfo) {
|
|||||||
IRQ_CALLBACK_LIST.push(IrqLine::acquire(i as u8).on_active(general_handler))
|
IRQ_CALLBACK_LIST.push(IrqLine::acquire(i as u8).on_active(general_handler))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
fn general_handler(trap_frame: TrapFrame) {
|
fn general_handler(trap_frame: TrapFrame) {
|
||||||
println!("{:?}", trap_frame);
|
println!("{:?}", trap_frame);
|
||||||
|
@ -4,10 +4,10 @@ use core::mem::size_of;
|
|||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
|
||||||
use crate::cell::Cell;
|
use crate::cell::Cell;
|
||||||
use crate::config::{PAGE_SIZE, KERNEL_STACK_SIZE};
|
use crate::config::{KERNEL_STACK_SIZE, PAGE_SIZE};
|
||||||
use crate::trap::{CalleeRegs, SyscallFrame, TrapFrame};
|
use crate::trap::{CalleeRegs, SyscallFrame, TrapFrame};
|
||||||
use crate::user::{syscall_switch_to_user_space, trap_switch_to_user_space, UserSpace};
|
use crate::user::{syscall_switch_to_user_space, trap_switch_to_user_space, UserSpace};
|
||||||
use crate::vm::{VmFrameVec, VmAllocOptions};
|
use crate::vm::{VmAllocOptions, VmFrameVec};
|
||||||
use crate::{prelude::*, UPSafeCell};
|
use crate::{prelude::*, UPSafeCell};
|
||||||
|
|
||||||
use super::processor::{current_task, schedule};
|
use super::processor::{current_task, schedule};
|
||||||
@ -84,7 +84,8 @@ pub struct KernelStack {
|
|||||||
impl KernelStack {
|
impl KernelStack {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
frame: VmFrameVec::allocate(&VmAllocOptions::new(KERNEL_STACK_SIZE/PAGE_SIZE)).expect("out of memory"),
|
frame: VmFrameVec::allocate(&VmAllocOptions::new(KERNEL_STACK_SIZE / PAGE_SIZE))
|
||||||
|
.expect("out of memory"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,8 +171,8 @@ impl Task {
|
|||||||
|
|
||||||
result.task_inner.exclusive_access().task_status = TaskStatus::Runnable;
|
result.task_inner.exclusive_access().task_status = TaskStatus::Runnable;
|
||||||
result.task_inner.exclusive_access().ctx.rip = kernel_task_entry as usize;
|
result.task_inner.exclusive_access().ctx.rip = kernel_task_entry as usize;
|
||||||
result.task_inner.exclusive_access().ctx.regs.rsp = result.kstack.frame.end_pa().unwrap().kvaddr().0
|
result.task_inner.exclusive_access().ctx.regs.rsp =
|
||||||
as usize
|
result.kstack.frame.end_pa().unwrap().kvaddr().0 as usize
|
||||||
- size_of::<usize>()
|
- size_of::<usize>()
|
||||||
- size_of::<SyscallFrame>();
|
- size_of::<SyscallFrame>();
|
||||||
|
|
||||||
@ -197,7 +198,13 @@ impl Task {
|
|||||||
|
|
||||||
pub(crate) fn trap_frame(&self) -> &mut TrapFrame {
|
pub(crate) fn trap_frame(&self) -> &mut TrapFrame {
|
||||||
unsafe {
|
unsafe {
|
||||||
&mut *(self.kstack.frame.end_pa().unwrap().kvaddr().get_mut::<TrapFrame>() as *mut TrapFrame)
|
&mut *(self
|
||||||
|
.kstack
|
||||||
|
.frame
|
||||||
|
.end_pa()
|
||||||
|
.unwrap()
|
||||||
|
.kvaddr()
|
||||||
|
.get_mut::<TrapFrame>() as *mut TrapFrame)
|
||||||
.sub(1)
|
.sub(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,15 +261,9 @@ fn read_segment_data<'a>(
|
|||||||
) -> Result<&'a [u8], &'static str> {
|
) -> Result<&'a [u8], &'static str> {
|
||||||
match segment.get_data(&elf_file) {
|
match segment.get_data(&elf_file) {
|
||||||
Err(msg) => Err(msg),
|
Err(msg) => Err(msg),
|
||||||
Ok(data) => {
|
Ok(data) => match data {
|
||||||
match data {
|
SegmentData::Note64(_, data) | SegmentData::Undefined(data) => Ok(data),
|
||||||
SegmentData::Note64(_, data) | SegmentData::Undefined(data) => {
|
_ => Err("Unkonwn segment data type"),
|
||||||
Ok(data)
|
|
||||||
},
|
},
|
||||||
_ => {
|
|
||||||
Err("Unkonwn segment data type")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
use alloc::sync::Arc;
|
use alloc::sync::Arc;
|
||||||
use kxos_frame::{
|
use kxos_frame::{
|
||||||
cpu::CpuContext,
|
cpu::CpuContext,
|
||||||
|
debug,
|
||||||
task::Task,
|
task::Task,
|
||||||
user::{UserEvent, UserMode, UserSpace},
|
user::{UserEvent, UserMode, UserSpace},
|
||||||
vm::VmSpace, debug,
|
vm::VmSpace,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{memory::load_elf_to_vm_space, syscall::syscall_handler};
|
use crate::{memory::load_elf_to_vm_space, syscall::syscall_handler};
|
||||||
|
Reference in New Issue
Block a user