mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-22 08:06:17 +04:00
Merge pull request #43 from equation314/clear-warning
Eliminate most of warnings
This commit is contained in:
commit
a2a5bd6079
@ -1,6 +1,5 @@
|
|||||||
use crate::drivers::bus::pci;
|
use crate::drivers::bus::pci;
|
||||||
use crate::drivers::gpu::fb::{self, FramebufferInfo};
|
use crate::drivers::gpu::fb::{self, FramebufferInfo};
|
||||||
use alloc::string::String;
|
|
||||||
use mips::registers::cp0;
|
use mips::registers::cp0;
|
||||||
|
|
||||||
pub mod consts;
|
pub mod consts;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use mips::registers::cp0;
|
use mips::registers::cp0;
|
||||||
use mips::tlb;
|
use mips::tlb::TLBEntry;
|
||||||
|
|
||||||
/// Saved registers on a trap.
|
/// Saved registers on a trap.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@ -238,7 +238,7 @@ impl Context {
|
|||||||
fn switch_context(src: *mut Context, dst: *mut Context);
|
fn switch_context(src: *mut Context, dst: *mut Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
tlb::clear_all_tlb();
|
TLBEntry::clear_all();
|
||||||
switch_context(self as *mut Context, target as *mut Context);
|
switch_context(self as *mut Context, target as *mut Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ pub fn halt() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn exit_in_qemu(error_code: u8) -> ! {
|
pub unsafe fn exit_in_qemu(_error_code: u8) -> ! {
|
||||||
/* nothing to do */
|
/* nothing to do */
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
pub use self::context::*;
|
pub use self::context::*;
|
||||||
use crate::arch::paging::get_root_page_table_ptr;
|
use crate::arch::paging::get_root_page_table_ptr;
|
||||||
use crate::drivers::{DRIVERS, IRQ_MANAGER};
|
use crate::drivers::IRQ_MANAGER;
|
||||||
use log::*;
|
use log::*;
|
||||||
use mips::addr::*;
|
use mips::addr::*;
|
||||||
use mips::interrupts;
|
use mips::interrupts;
|
||||||
use mips::paging::{
|
use mips::paging::PageTable as MIPSPageTable;
|
||||||
PageTable as MIPSPageTable, PageTableEntry, PageTableFlags as EF, TwoLevelPageTable,
|
|
||||||
};
|
|
||||||
use mips::registers::cp0;
|
use mips::registers::cp0;
|
||||||
use mips::tlb;
|
|
||||||
|
|
||||||
#[path = "context.rs"]
|
#[path = "context.rs"]
|
||||||
mod context;
|
mod context;
|
||||||
@ -154,7 +151,7 @@ fn syscall(tf: &mut TrapFrame) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// temporary solution for ThinPad
|
// temporary solution for ThinPad
|
||||||
if (tf.v0 == 0) {
|
if tf.v0 == 0 {
|
||||||
warn!("Syscall ID = 0");
|
warn!("Syscall ID = 0");
|
||||||
tf.v0 = unsafe { *((tf.sp + 28) as *const usize) };
|
tf.v0 = unsafe { *((tf.sp + 28) as *const usize) };
|
||||||
}
|
}
|
||||||
@ -162,7 +159,7 @@ fn syscall(tf: &mut TrapFrame) {
|
|||||||
let ret = crate::syscall::syscall(tf.v0, arguments, tf) as isize;
|
let ret = crate::syscall::syscall(tf.v0, arguments, tf) as isize;
|
||||||
// comply with mips n32 abi, always return a positive value
|
// comply with mips n32 abi, always return a positive value
|
||||||
// https://git.musl-libc.org/cgit/musl/tree/arch/mipsn32/syscall_arch.h
|
// https://git.musl-libc.org/cgit/musl/tree/arch/mipsn32/syscall_arch.h
|
||||||
if (ret < 0) {
|
if ret < 0 {
|
||||||
tf.v0 = (-ret) as usize;
|
tf.v0 = (-ret) as usize;
|
||||||
tf.a3 = 1;
|
tf.a3 = 1;
|
||||||
} else {
|
} else {
|
||||||
@ -282,7 +279,7 @@ fn page_fault(tf: &mut TrapFrame) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tlb::write_tlb_random(tlb_entry)
|
tlb_entry.write_random()
|
||||||
}
|
}
|
||||||
Err(()) => {
|
Err(()) => {
|
||||||
if !crate::memory::handle_page_fault(addr) {
|
if !crate::memory::handle_page_fault(addr) {
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
use crate::arch::paging::*;
|
use crate::arch::paging::*;
|
||||||
use crate::consts::{KERNEL_OFFSET, MEMORY_END, MEMORY_OFFSET};
|
use crate::consts::{KERNEL_OFFSET, MEMORY_END, MEMORY_OFFSET};
|
||||||
use crate::memory::{init_heap, Linear, MemoryAttr, MemorySet, FRAME_ALLOCATOR};
|
use crate::memory::{init_heap, FRAME_ALLOCATOR};
|
||||||
use core::mem;
|
|
||||||
use log::*;
|
|
||||||
use rcore_memory::PAGE_SIZE;
|
use rcore_memory::PAGE_SIZE;
|
||||||
|
|
||||||
/// Initialize the memory management module
|
/// Initialize the memory management module
|
||||||
@ -46,10 +44,6 @@ fn init_frame_allocator() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// First core stores its SATP here.
|
|
||||||
// Other cores load it later.
|
|
||||||
static mut SATP: usize = 0;
|
|
||||||
|
|
||||||
pub unsafe fn clear_bss() {
|
pub unsafe fn clear_bss() {
|
||||||
let start = sbss as usize;
|
let start = sbss as usize;
|
||||||
let end = ebss as usize;
|
let end = ebss as usize;
|
||||||
|
@ -9,7 +9,6 @@ pub mod rand;
|
|||||||
pub mod syscall;
|
pub mod syscall;
|
||||||
pub mod timer;
|
pub mod timer;
|
||||||
|
|
||||||
use log::*;
|
|
||||||
use mips::registers::cp0;
|
use mips::registers::cp0;
|
||||||
|
|
||||||
#[cfg(feature = "board_malta")]
|
#[cfg(feature = "board_malta")]
|
||||||
@ -62,12 +61,14 @@ pub extern "C" fn rust_main() -> ! {
|
|||||||
crate::kmain();
|
crate::kmain();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
fn others_main() -> ! {
|
fn others_main() -> ! {
|
||||||
interrupt::init();
|
interrupt::init();
|
||||||
memory::init_other();
|
memory::init_other();
|
||||||
timer::init();
|
timer::init();
|
||||||
crate::kmain();
|
crate::kmain();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
const BOOT_CPU_ID: u32 = 0;
|
const BOOT_CPU_ID: u32 = 0;
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ impl Entry for PageEntry {
|
|||||||
fn readonly_shared(&self) -> bool {
|
fn readonly_shared(&self) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
fn set_shared(&mut self, writable: bool) {}
|
fn set_shared(&mut self, _writable: bool) {}
|
||||||
fn clear_shared(&mut self) {}
|
fn clear_shared(&mut self) {}
|
||||||
fn swapped(&self) -> bool {
|
fn swapped(&self) -> bool {
|
||||||
self.0.flags().contains(EF::RESERVED1)
|
self.0.flags().contains(EF::RESERVED1)
|
||||||
@ -136,11 +136,11 @@ impl Entry for PageEntry {
|
|||||||
fn user(&self) -> bool {
|
fn user(&self) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
fn set_user(&mut self, value: bool) {}
|
fn set_user(&mut self, _value: bool) {}
|
||||||
fn execute(&self) -> bool {
|
fn execute(&self) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
fn set_execute(&mut self, value: bool) {}
|
fn set_execute(&mut self, _value: bool) {}
|
||||||
fn mmio(&self) -> u8 {
|
fn mmio(&self) -> u8 {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ pub fn halt() {
|
|||||||
unsafe { riscv::asm::wfi() }
|
unsafe { riscv::asm::wfi() }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn exit_in_qemu(error_code: u8) -> ! {
|
pub unsafe fn exit_in_qemu(_error_code: u8) -> ! {
|
||||||
super::sbi::shutdown()
|
super::sbi::shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
pub use self::context::*;
|
pub use self::context::*;
|
||||||
use crate::drivers::{DRIVERS, IRQ_MANAGER};
|
use crate::drivers::IRQ_MANAGER;
|
||||||
use log::*;
|
use log::*;
|
||||||
use riscv::register::*;
|
use riscv::register::*;
|
||||||
|
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
use crate::consts::{KERNEL_OFFSET, MEMORY_END, MEMORY_OFFSET, PHYSICAL_MEMORY_OFFSET};
|
use crate::consts::{KERNEL_OFFSET, MEMORY_END, MEMORY_OFFSET};
|
||||||
use crate::memory::{init_heap, Linear, MemoryAttr, MemorySet, FRAME_ALLOCATOR};
|
use crate::memory::{init_heap, MemorySet, FRAME_ALLOCATOR};
|
||||||
use core::mem;
|
use core::mem;
|
||||||
use log::*;
|
use log::*;
|
||||||
use rcore_memory::PAGE_SIZE;
|
use rcore_memory::PAGE_SIZE;
|
||||||
use riscv::register::satp;
|
use riscv::register::sstatus;
|
||||||
use riscv::{addr::*, register::sstatus};
|
|
||||||
|
|
||||||
/// Initialize the memory management module
|
/// Initialize the memory management module
|
||||||
pub fn init(dtb: usize) {
|
pub fn init(dtb: usize) {
|
||||||
@ -51,7 +50,7 @@ fn init_frame_allocator() {
|
|||||||
|
|
||||||
/// Remap the kernel memory address with 4K page recorded in p1 page table
|
/// Remap the kernel memory address with 4K page recorded in p1 page table
|
||||||
fn remap_the_kernel(_dtb: usize) {
|
fn remap_the_kernel(_dtb: usize) {
|
||||||
let mut ms = MemorySet::new();
|
let ms = MemorySet::new();
|
||||||
unsafe {
|
unsafe {
|
||||||
ms.activate();
|
ms.activate();
|
||||||
}
|
}
|
||||||
|
@ -22,20 +22,17 @@ pub mod timer;
|
|||||||
|
|
||||||
use crate::memory::phys_to_virt;
|
use crate::memory::phys_to_virt;
|
||||||
use core::sync::atomic::{AtomicBool, Ordering};
|
use core::sync::atomic::{AtomicBool, Ordering};
|
||||||
use log::*;
|
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn rust_main(hartid: usize, device_tree_paddr: usize) -> ! {
|
pub extern "C" fn rust_main(hartid: usize, device_tree_paddr: usize) -> ! {
|
||||||
let mut device_tree_vaddr = phys_to_virt(device_tree_paddr);
|
let device_tree_vaddr = phys_to_virt(device_tree_paddr);
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
cpu::set_cpu_id(hartid);
|
cpu::set_cpu_id(hartid);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "board_rocket_chip")]
|
#[cfg(feature = "board_rocket_chip")]
|
||||||
{
|
let device_tree_vaddr = board::DTB.as_ptr() as usize;
|
||||||
device_tree_vaddr = board::DTB.as_ptr() as usize;
|
|
||||||
}
|
|
||||||
|
|
||||||
if hartid != BOOT_HART_ID {
|
if hartid != BOOT_HART_ID {
|
||||||
while !AP_CAN_INIT.load(Ordering::Relaxed) {}
|
while !AP_CAN_INIT.load(Ordering::Relaxed) {}
|
||||||
@ -88,7 +85,7 @@ const BOOT_HART_ID: usize = 0;
|
|||||||
#[cfg(feature = "board_u540")]
|
#[cfg(feature = "board_u540")]
|
||||||
const BOOT_HART_ID: usize = 1;
|
const BOOT_HART_ID: usize = 1;
|
||||||
|
|
||||||
/// Constant & Macro for `trap.asm`
|
// Constant & Macro for `trap.asm`
|
||||||
#[cfg(target_arch = "riscv32")]
|
#[cfg(target_arch = "riscv32")]
|
||||||
global_asm!(
|
global_asm!(
|
||||||
r"
|
r"
|
||||||
|
@ -6,11 +6,7 @@ use rcore_memory::paging::*;
|
|||||||
use riscv::addr::*;
|
use riscv::addr::*;
|
||||||
use riscv::asm::{sfence_vma, sfence_vma_all};
|
use riscv::asm::{sfence_vma, sfence_vma_all};
|
||||||
use riscv::paging::{FrameAllocator, FrameDeallocator};
|
use riscv::paging::{FrameAllocator, FrameDeallocator};
|
||||||
use riscv::paging::{
|
use riscv::paging::{Mapper, PageTable as RvPageTable, PageTableEntry, PageTableFlags as EF};
|
||||||
Mapper, PageTable as RvPageTable, PageTableEntry, PageTableFlags as EF, PageTableType,
|
|
||||||
RecursivePageTable,
|
|
||||||
};
|
|
||||||
use riscv::register::satp;
|
|
||||||
|
|
||||||
#[cfg(target_arch = "riscv32")]
|
#[cfg(target_arch = "riscv32")]
|
||||||
type TopLevelPageTable<'a> = riscv::paging::Rv32PageTable<'a>;
|
type TopLevelPageTable<'a> = riscv::paging::Rv32PageTable<'a>;
|
||||||
@ -199,7 +195,7 @@ impl PageTableExt for PageTableImpl {
|
|||||||
}
|
}
|
||||||
#[cfg(target_arch = "riscv64")]
|
#[cfg(target_arch = "riscv64")]
|
||||||
for i in 509..512 {
|
for i in 509..512 {
|
||||||
if (i == 510) {
|
if i == 510 {
|
||||||
// MMIO range 0x60000000 - 0x7FFFFFFF does not work as a large page, dunno why
|
// MMIO range 0x60000000 - 0x7FFFFFFF does not work as a large page, dunno why
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -212,40 +208,40 @@ impl PageTableExt for PageTableImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MMIO range 0x60000000 - 0x7FFFFFFF does not work as a large page, dunno why
|
// MMIO range 0x60000000 - 0x7FFFFFFF does not work as a large page, dunno why
|
||||||
let flags = EF::VALID | EF::READABLE | EF::WRITABLE;
|
|
||||||
// map Uartlite for Rocket Chip
|
// map Uartlite for Rocket Chip
|
||||||
#[cfg(feature = "board_rocket_chip")]
|
#[cfg(feature = "board_rocket_chip")]
|
||||||
self.page_table
|
{
|
||||||
.map_to(
|
let flags = EF::VALID | EF::READABLE | EF::WRITABLE;
|
||||||
Page::of_addr(VirtAddr::new(PHYSICAL_MEMORY_OFFSET + 0x6000_0000)),
|
self.page_table
|
||||||
Frame::of_addr(PhysAddr::new(0x6000_0000)),
|
.map_to(
|
||||||
flags,
|
Page::of_addr(VirtAddr::new(PHYSICAL_MEMORY_OFFSET + 0x6000_0000)),
|
||||||
&mut FrameAllocatorForRiscv,
|
Frame::of_addr(PhysAddr::new(0x6000_0000)),
|
||||||
)
|
flags,
|
||||||
.unwrap()
|
&mut FrameAllocatorForRiscv,
|
||||||
.flush();
|
)
|
||||||
// map AXI INTC for Rocket Chip
|
.unwrap()
|
||||||
#[cfg(feature = "board_rocket_chip")]
|
.flush();
|
||||||
self.page_table
|
// map AXI INTC for Rocket Chip
|
||||||
.map_to(
|
self.page_table
|
||||||
Page::of_addr(VirtAddr::new(PHYSICAL_MEMORY_OFFSET + 0x6120_0000)),
|
.map_to(
|
||||||
Frame::of_addr(PhysAddr::new(0x6120_0000)),
|
Page::of_addr(VirtAddr::new(PHYSICAL_MEMORY_OFFSET + 0x6120_0000)),
|
||||||
flags,
|
Frame::of_addr(PhysAddr::new(0x6120_0000)),
|
||||||
&mut FrameAllocatorForRiscv,
|
flags,
|
||||||
)
|
&mut FrameAllocatorForRiscv,
|
||||||
.unwrap()
|
)
|
||||||
.flush();
|
.unwrap()
|
||||||
// map AXI4-Stream Data FIFO for Rocket Chip
|
.flush();
|
||||||
#[cfg(feature = "board_rocket_chip")]
|
// map AXI4-Stream Data FIFO for Rocket Chip
|
||||||
self.page_table
|
self.page_table
|
||||||
.map_to(
|
.map_to(
|
||||||
Page::of_addr(VirtAddr::new(PHYSICAL_MEMORY_OFFSET + 0x64A0_0000)),
|
Page::of_addr(VirtAddr::new(PHYSICAL_MEMORY_OFFSET + 0x64A0_0000)),
|
||||||
Frame::of_addr(PhysAddr::new(0x64A0_0000)),
|
Frame::of_addr(PhysAddr::new(0x64A0_0000)),
|
||||||
flags,
|
flags,
|
||||||
&mut FrameAllocatorForRiscv,
|
&mut FrameAllocatorForRiscv,
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.flush();
|
.flush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn token(&self) -> usize {
|
fn token(&self) -> usize {
|
||||||
@ -260,7 +256,7 @@ impl PageTableExt for PageTableImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn active_token() -> usize {
|
fn active_token() -> usize {
|
||||||
let mut token: usize = 0;
|
let mut token;
|
||||||
unsafe {
|
unsafe {
|
||||||
asm!("csrr $0, satp" : "=r"(token) ::: "volatile");
|
asm!("csrr $0, satp" : "=r"(token) ::: "volatile");
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ impl AcpiHandler for Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unmap_physical_region<T>(&mut self, region: PhysicalMapping<T>) {
|
fn unmap_physical_region<T>(&mut self, _region: PhysicalMapping<T>) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
use crate::consts::KERNEL_OFFSET;
|
|
||||||
use crate::drivers::gpu::fb::{self, ColorDepth, ColorFormat, FramebufferInfo};
|
use crate::drivers::gpu::fb::{self, ColorDepth, ColorFormat, FramebufferInfo};
|
||||||
use crate::memory::phys_to_virt;
|
use crate::memory::phys_to_virt;
|
||||||
use core::mem::zeroed;
|
|
||||||
use rboot::BootInfo;
|
use rboot::BootInfo;
|
||||||
|
|
||||||
pub fn init_driver(boot_info: &BootInfo) {
|
pub fn init_driver(boot_info: &BootInfo) {
|
||||||
@ -17,7 +15,7 @@ pub fn init_driver(boot_info: &BootInfo) {
|
|||||||
xoffset: 0,
|
xoffset: 0,
|
||||||
yoffset: 0,
|
yoffset: 0,
|
||||||
depth: ColorDepth::ColorDepth32,
|
depth: ColorDepth::ColorDepth32,
|
||||||
format: fb::ColorFormat::RGBA8888,
|
format: ColorFormat::RGBA8888,
|
||||||
paddr: info.fb_addr as usize,
|
paddr: info.fb_addr as usize,
|
||||||
vaddr: phys_to_virt(info.fb_addr as usize),
|
vaddr: phys_to_virt(info.fb_addr as usize),
|
||||||
screen_size: info.fb_size as usize,
|
screen_size: info.fb_size as usize,
|
||||||
|
@ -5,7 +5,7 @@ pub mod serial;
|
|||||||
|
|
||||||
use super::BootInfo;
|
use super::BootInfo;
|
||||||
|
|
||||||
pub fn init(boot_info: &BootInfo) {
|
pub fn init(_boot_info: &BootInfo) {
|
||||||
serial::init();
|
serial::init();
|
||||||
keyboard::init();
|
keyboard::init();
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
|
|
||||||
use super::consts::*;
|
use super::consts::*;
|
||||||
use super::TrapFrame;
|
use super::TrapFrame;
|
||||||
use crate::drivers::{DRIVERS, IRQ_MANAGER};
|
use crate::drivers::IRQ_MANAGER;
|
||||||
use bitflags::*;
|
use bitflags::*;
|
||||||
use log::*;
|
use log::*;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ use core::sync::atomic::{spin_loop_hint, AtomicU8, Ordering};
|
|||||||
pub type IPIEventItem = Box<dyn Fn()>;
|
pub type IPIEventItem = Box<dyn Fn()>;
|
||||||
|
|
||||||
unsafe fn get_apic() -> XApic {
|
unsafe fn get_apic() -> XApic {
|
||||||
let mut lapic = XApic::new(phys_to_virt(LAPIC_ADDR));
|
let lapic = XApic::new(phys_to_virt(LAPIC_ADDR));
|
||||||
lapic
|
lapic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
use super::consts::*;
|
use super::consts::*;
|
||||||
use crate::memory::{alloc_frame, dealloc_frame, phys_to_virt};
|
use crate::memory::{alloc_frame, dealloc_frame, phys_to_virt};
|
||||||
use core::mem::ManuallyDrop;
|
use core::mem::ManuallyDrop;
|
||||||
use core::sync::atomic::Ordering;
|
|
||||||
use log::*;
|
use log::*;
|
||||||
use rcore_memory::paging::*;
|
use rcore_memory::paging::*;
|
||||||
use x86_64::instructions::tlb;
|
use x86_64::instructions::tlb;
|
||||||
@ -284,11 +283,11 @@ impl FrameDeallocator<Size4KiB> for FrameAllocatorForX86 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Flush TLB for `vaddr` on all CPU
|
/// Flush TLB for `vaddr` on all CPU
|
||||||
fn flush_tlb_all(vaddr: usize) {
|
fn flush_tlb_all(_vaddr: usize) {
|
||||||
// FIXME: too slow, disable now.
|
// FIXME: too slow, disable now.
|
||||||
return;
|
return;
|
||||||
if !super::AP_CAN_INIT.load(Ordering::Relaxed) {
|
// if !super::AP_CAN_INIT.load(Ordering::Relaxed) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
super::ipi::invoke_on_allcpu(move || tlb::flush(VirtAddr::new(vaddr as u64)), false);
|
// super::ipi::invoke_on_allcpu(move || tlb::flush(VirtAddr::new(vaddr as u64)), false);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use core::mem::size_of;
|
use core::mem::size_of;
|
||||||
use rcore_memory::PAGE_SIZE;
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn stext();
|
fn stext();
|
||||||
@ -165,6 +164,7 @@ pub fn backtrace() {
|
|||||||
// Kernel stack at 0x0000_57ac_0000_0000 (defined in bootloader crate)
|
// Kernel stack at 0x0000_57ac_0000_0000 (defined in bootloader crate)
|
||||||
// size = 512 pages
|
// size = 512 pages
|
||||||
current_fp = *(current_fp as *const usize).offset(0);
|
current_fp = *(current_fp as *const usize).offset(0);
|
||||||
|
use rcore_memory::PAGE_SIZE;
|
||||||
if current_fp >= 0x0000_57ac_0000_0000 + 512 * PAGE_SIZE - size_of::<usize>()
|
if current_fp >= 0x0000_57ac_0000_0000 + 512 * PAGE_SIZE - size_of::<usize>()
|
||||||
&& current_fp <= 0xffff_ff00_0000_0000
|
&& current_fp <= 0xffff_ff00_0000_0000
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
use alloc::string::String;
|
use alloc::string::String;
|
||||||
use alloc::sync::Arc;
|
use alloc::sync::Arc;
|
||||||
|
|
||||||
use log::*;
|
|
||||||
use virtio_drivers::{VirtIOBlk, VirtIOHeader};
|
use virtio_drivers::{VirtIOBlk, VirtIOHeader};
|
||||||
|
|
||||||
use super::super::{DeviceType, Driver, BLK_DRIVERS, DRIVERS, IRQ_MANAGER};
|
use super::super::{DeviceType, Driver, BLK_DRIVERS, DRIVERS, IRQ_MANAGER};
|
||||||
use crate::memory::phys_to_virt;
|
|
||||||
use crate::sync::SpinNoIrqLock as Mutex;
|
use crate::sync::SpinNoIrqLock as Mutex;
|
||||||
|
|
||||||
struct VirtIOBlkDriver(Mutex<VirtIOBlk<'static>>);
|
struct VirtIOBlkDriver(Mutex<VirtIOBlk<'static>>);
|
||||||
|
@ -8,7 +8,7 @@ use super::super::block::virtio_blk;
|
|||||||
use super::super::gpu::virtio_gpu;
|
use super::super::gpu::virtio_gpu;
|
||||||
use super::super::input::virtio_input;
|
use super::super::input::virtio_input;
|
||||||
use super::super::net::virtio_net;
|
use super::super::net::virtio_net;
|
||||||
use crate::memory::{phys_to_virt, virt_to_phys};
|
use crate::memory::phys_to_virt;
|
||||||
|
|
||||||
pub fn virtio_probe(node: &Node) {
|
pub fn virtio_probe(node: &Node) {
|
||||||
let reg = match node.prop_raw("reg") {
|
let reg = match node.prop_raw("reg") {
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
use alloc::string::String;
|
use alloc::string::String;
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use log::*;
|
use log::*;
|
||||||
use spin::RwLock;
|
use spin::RwLock;
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
//! driver for qemu stdvga (Cirrus)
|
//! driver for qemu stdvga (Cirrus)
|
||||||
|
|
||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use crate::util::{read, write};
|
use crate::util::{read, write};
|
||||||
|
|
||||||
const VGA_MMIO_OFFSET: usize = 0x400 - 0x3C0;
|
const VGA_MMIO_OFFSET: usize = 0x400 - 0x3C0;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
use alloc::string::String;
|
use alloc::string::String;
|
||||||
use alloc::sync::Arc;
|
use alloc::sync::Arc;
|
||||||
|
|
||||||
use log::*;
|
|
||||||
use virtio_drivers::{VirtIOGpu, VirtIOHeader};
|
use virtio_drivers::{VirtIOGpu, VirtIOHeader};
|
||||||
|
|
||||||
use super::super::{DeviceType, Driver, DRIVERS, IRQ_MANAGER};
|
use super::super::{DeviceType, Driver, DRIVERS, IRQ_MANAGER};
|
||||||
|
@ -31,7 +31,7 @@ impl Driver for VirtIOInputDriver {
|
|||||||
|
|
||||||
pub fn init(header: &'static mut VirtIOHeader) {
|
pub fn init(header: &'static mut VirtIOHeader) {
|
||||||
let event_buf = Box::leak(Box::new([0u64; 32]));
|
let event_buf = Box::leak(Box::new([0u64; 32]));
|
||||||
let mut input = VirtIOInput::new(header, event_buf).expect("failed to create input driver");
|
let input = VirtIOInput::new(header, event_buf).expect("failed to create input driver");
|
||||||
|
|
||||||
let driver = Arc::new(VirtIOInputDriver(Mutex::new(input)));
|
let driver = Arc::new(VirtIOInputDriver(Mutex::new(input)));
|
||||||
IRQ_MANAGER.write().register_all(driver.clone());
|
IRQ_MANAGER.write().register_all(driver.clone());
|
||||||
|
@ -14,6 +14,7 @@ pub mod block;
|
|||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub mod bus;
|
pub mod bus;
|
||||||
pub mod console;
|
pub mod console;
|
||||||
|
#[allow(dead_code)]
|
||||||
mod device_tree;
|
mod device_tree;
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub mod gpu;
|
pub mod gpu;
|
||||||
|
@ -159,10 +159,10 @@ impl Driver for RouterInterface {
|
|||||||
let rdfo = AXI_STREAM_FIFO_RDFO.read_volatile();
|
let rdfo = AXI_STREAM_FIFO_RDFO.read_volatile();
|
||||||
if rdfo > 0 {
|
if rdfo > 0 {
|
||||||
let mut buffer = Vec::new();
|
let mut buffer = Vec::new();
|
||||||
let rlr = AXI_STREAM_FIFO_RLR.read_volatile();
|
let _rlr = AXI_STREAM_FIFO_RLR.read_volatile();
|
||||||
let rdr = AXI_STREAM_FIFO_RDR.read_volatile();
|
let _rdr = AXI_STREAM_FIFO_RDR.read_volatile();
|
||||||
let port = AXI_STREAM_FIFO_RDFD.read_volatile();
|
let port = AXI_STREAM_FIFO_RDFD.read_volatile();
|
||||||
for i in 1..rdfo {
|
for _ in 1..rdfo {
|
||||||
buffer.push(AXI_STREAM_FIFO_RDFD.read_volatile() as u8);
|
buffer.push(AXI_STREAM_FIFO_RDFD.read_volatile() as u8);
|
||||||
}
|
}
|
||||||
debug!(
|
debug!(
|
||||||
|
@ -2,7 +2,6 @@ use alloc::format;
|
|||||||
use alloc::string::String;
|
use alloc::string::String;
|
||||||
use alloc::sync::Arc;
|
use alloc::sync::Arc;
|
||||||
|
|
||||||
use log::*;
|
|
||||||
use smoltcp::phy::{self, DeviceCapabilities};
|
use smoltcp::phy::{self, DeviceCapabilities};
|
||||||
use smoltcp::time::Instant;
|
use smoltcp::time::Instant;
|
||||||
use smoltcp::wire::{EthernetAddress, Ipv4Address};
|
use smoltcp::wire::{EthernetAddress, Ipv4Address};
|
||||||
@ -10,7 +9,6 @@ use smoltcp::Result;
|
|||||||
use virtio_drivers::{VirtIOHeader, VirtIONet};
|
use virtio_drivers::{VirtIOHeader, VirtIONet};
|
||||||
|
|
||||||
use super::super::{DeviceType, Driver, DRIVERS, IRQ_MANAGER, NET_DRIVERS};
|
use super::super::{DeviceType, Driver, DRIVERS, IRQ_MANAGER, NET_DRIVERS};
|
||||||
use crate::memory::phys_to_virt;
|
|
||||||
use crate::sync::SpinNoIrqLock as Mutex;
|
use crate::sync::SpinNoIrqLock as Mutex;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@ -51,7 +49,7 @@ impl phy::Device<'_> for VirtIONetDriver {
|
|||||||
type TxToken = VirtIONetDriver;
|
type TxToken = VirtIONetDriver;
|
||||||
|
|
||||||
fn receive(&mut self) -> Option<(Self::RxToken, Self::TxToken)> {
|
fn receive(&mut self) -> Option<(Self::RxToken, Self::TxToken)> {
|
||||||
let mut net = self.0.lock();
|
let net = self.0.lock();
|
||||||
if net.can_recv() {
|
if net.can_recv() {
|
||||||
Some((self.clone(), self.clone()))
|
Some((self.clone(), self.clone()))
|
||||||
} else {
|
} else {
|
||||||
@ -60,7 +58,7 @@ impl phy::Device<'_> for VirtIONetDriver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn transmit(&mut self) -> Option<Self::TxToken> {
|
fn transmit(&mut self) -> Option<Self::TxToken> {
|
||||||
let mut net = self.0.lock();
|
let net = self.0.lock();
|
||||||
if net.can_send() {
|
if net.can_send() {
|
||||||
Some(self.clone())
|
Some(self.clone())
|
||||||
} else {
|
} else {
|
||||||
|
@ -29,7 +29,7 @@ impl INode for Fbdev {
|
|||||||
offset,
|
offset,
|
||||||
buf.len()
|
buf.len()
|
||||||
);
|
);
|
||||||
if let Some(mut fb) = FRAME_BUFFER.write().as_mut() {
|
if let Some(fb) = FRAME_BUFFER.write().as_mut() {
|
||||||
let count = fb.write_at(offset, buf);
|
let count = fb.write_at(offset, buf);
|
||||||
if count == buf.len() {
|
if count == buf.len() {
|
||||||
Ok(count)
|
Ok(count)
|
||||||
@ -119,6 +119,7 @@ impl INode for Fbdev {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
enum FbType {
|
enum FbType {
|
||||||
/// Packed Pixels
|
/// Packed Pixels
|
||||||
@ -136,6 +137,7 @@ enum FbType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
enum FbVisual {
|
enum FbVisual {
|
||||||
/// Monochr. 1=Black 0=White
|
/// Monochr. 1=Black 0=White
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
//! Implement INode for RandomINode
|
//! Implement INode for RandomINode
|
||||||
|
|
||||||
use alloc::{collections::vec_deque::VecDeque, string::String, sync::Arc};
|
use alloc::sync::Arc;
|
||||||
use core::any::Any;
|
use core::any::Any;
|
||||||
|
|
||||||
use rcore_fs::vfs::*;
|
use rcore_fs::vfs::*;
|
||||||
|
|
||||||
use crate::sync::Condvar;
|
|
||||||
use crate::sync::SpinNoIrqLock as Mutex;
|
use crate::sync::SpinNoIrqLock as Mutex;
|
||||||
|
|
||||||
struct RandomINodeData {
|
struct RandomINodeData {
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
//! Implement INode for Stdin & Stdout
|
//! Implement INode for Stdin & Stdout
|
||||||
|
|
||||||
use alloc::{collections::vec_deque::VecDeque, string::String, sync::Arc};
|
use alloc::{collections::vec_deque::VecDeque, sync::Arc};
|
||||||
use core::any::Any;
|
use core::any::Any;
|
||||||
|
|
||||||
use rcore_fs::vfs::*;
|
use rcore_fs::vfs::*;
|
||||||
|
|
||||||
use crate::fs::ioctl::*;
|
use crate::fs::ioctl::*;
|
||||||
use crate::process::Process;
|
|
||||||
use crate::sync::Condvar;
|
use crate::sync::Condvar;
|
||||||
use crate::sync::SpinNoIrqLock as Mutex;
|
use crate::sync::SpinNoIrqLock as Mutex;
|
||||||
|
|
||||||
@ -55,7 +54,7 @@ lazy_static! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl INode for Stdin {
|
impl INode for Stdin {
|
||||||
fn read_at(&self, offset: usize, buf: &mut [u8]) -> Result<usize> {
|
fn read_at(&self, _offset: usize, buf: &mut [u8]) -> Result<usize> {
|
||||||
if self.can_read() {
|
if self.can_read() {
|
||||||
buf[0] = self.pop() as u8;
|
buf[0] = self.pop() as u8;
|
||||||
Ok(1)
|
Ok(1)
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
//! Implement Device
|
//! Implement Device
|
||||||
|
|
||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use rcore_fs::dev::*;
|
use rcore_fs::dev::*;
|
||||||
use spin::RwLock;
|
use spin::RwLock;
|
||||||
|
|
||||||
@ -8,6 +10,7 @@ use crate::arch::driver::ide;
|
|||||||
|
|
||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
use crate::arch::board::emmc;
|
use crate::arch::board::emmc;
|
||||||
|
#[cfg(target_arch = "aarch64")]
|
||||||
use crate::sync::SpinNoIrqLock as Mutex;
|
use crate::sync::SpinNoIrqLock as Mutex;
|
||||||
|
|
||||||
pub struct MemBuf(RwLock<&'static mut [u8]>);
|
pub struct MemBuf(RwLock<&'static mut [u8]>);
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
use crate::fs::FileLike;
|
use crate::fs::FileLike;
|
||||||
use crate::memory::MemorySet;
|
|
||||||
use crate::process::Process;
|
use crate::process::Process;
|
||||||
use crate::sync::{Condvar, SpinNoIrqLock};
|
use crate::sync::SpinNoIrqLock;
|
||||||
use crate::syscall::{SysError, SysResult};
|
use crate::syscall::{SysError, SysResult};
|
||||||
use alloc::{collections::BTreeMap, collections::BTreeSet};
|
use alloc::{collections::BTreeMap, collections::BTreeSet};
|
||||||
use core::mem::size_of;
|
|
||||||
use core::slice;
|
|
||||||
|
|
||||||
pub struct EpollInstance {
|
pub struct EpollInstance {
|
||||||
pub events: BTreeMap<usize, EpollEvent>,
|
pub events: BTreeMap<usize, EpollEvent>,
|
||||||
pub readyList: SpinNoIrqLock<BTreeSet<usize>>,
|
pub ready_list: SpinNoIrqLock<BTreeSet<usize>>,
|
||||||
pub newCtlList: SpinNoIrqLock<BTreeSet<usize>>,
|
pub new_ctl_list: SpinNoIrqLock<BTreeSet<usize>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clone for EpollInstance {
|
impl Clone for EpollInstance {
|
||||||
@ -20,26 +17,26 @@ impl Clone for EpollInstance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl EpollInstance {
|
impl EpollInstance {
|
||||||
pub fn new(flags: usize) -> Self {
|
pub fn new(_flags: usize) -> Self {
|
||||||
return EpollInstance {
|
return EpollInstance {
|
||||||
events: BTreeMap::new(),
|
events: BTreeMap::new(),
|
||||||
readyList: Default::default(),
|
ready_list: Default::default(),
|
||||||
newCtlList: Default::default(),
|
new_ctl_list: Default::default(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn control(&mut self, op: usize, fd: usize, event: &EpollEvent) -> SysResult {
|
pub fn control(&mut self, op: usize, fd: usize, event: &EpollEvent) -> SysResult {
|
||||||
match (op as i32) {
|
match op as i32 {
|
||||||
EPollCtlOp::ADD => {
|
EPollCtlOp::ADD => {
|
||||||
self.events.insert(fd, event.clone());
|
self.events.insert(fd, event.clone());
|
||||||
self.newCtlList.lock().insert(fd);
|
self.new_ctl_list.lock().insert(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
EPollCtlOp::MOD => {
|
EPollCtlOp::MOD => {
|
||||||
if self.events.get(&fd).is_some() {
|
if self.events.get(&fd).is_some() {
|
||||||
self.events.remove(&fd);
|
self.events.remove(&fd);
|
||||||
self.events.insert(fd, event.clone());
|
self.events.insert(fd, event.clone());
|
||||||
self.newCtlList.lock().insert(fd);
|
self.new_ctl_list.lock().insert(fd);
|
||||||
} else {
|
} else {
|
||||||
return Err(SysError::EPERM);
|
return Err(SysError::EPERM);
|
||||||
}
|
}
|
||||||
@ -62,10 +59,9 @@ impl EpollInstance {
|
|||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct EpollData {
|
pub struct EpollData {
|
||||||
ptr: u64,
|
_ptr: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(packed)]
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct EpollEvent {
|
pub struct EpollEvent {
|
||||||
pub events: u32, /* Epoll events */
|
pub events: u32, /* Epoll events */
|
||||||
|
@ -54,14 +54,12 @@ impl FileHandle {
|
|||||||
if !self.options.read {
|
if !self.options.read {
|
||||||
return Err(FsError::InvalidParam); // FIXME: => EBADF
|
return Err(FsError::InvalidParam); // FIXME: => EBADF
|
||||||
}
|
}
|
||||||
let mut len: usize = 0;
|
|
||||||
if !self.options.nonblock {
|
if !self.options.nonblock {
|
||||||
// block
|
// block
|
||||||
loop {
|
loop {
|
||||||
match self.inode.read_at(offset, buf) {
|
match self.inode.read_at(offset, buf) {
|
||||||
Ok(read_len) => {
|
Ok(read_len) => {
|
||||||
len = read_len;
|
return Ok(read_len);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
Err(FsError::Again) => {
|
Err(FsError::Again) => {
|
||||||
thread::yield_now();
|
thread::yield_now();
|
||||||
@ -72,9 +70,9 @@ impl FileHandle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
len = self.inode.read_at(offset, buf)?;
|
let len = self.inode.read_at(offset, buf)?;
|
||||||
|
Ok(len)
|
||||||
}
|
}
|
||||||
Ok(len)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write(&mut self, buf: &[u8]) -> Result<usize> {
|
pub fn write(&mut self, buf: &[u8]) -> Result<usize> {
|
||||||
@ -150,7 +148,7 @@ impl FileHandle {
|
|||||||
match self.inode.metadata()?.type_ {
|
match self.inode.metadata()?.type_ {
|
||||||
FileType::File => {
|
FileType::File => {
|
||||||
let prot = MmapProt::from_bits_truncate(area.prot);
|
let prot = MmapProt::from_bits_truncate(area.prot);
|
||||||
let thread = unsafe { crate::process::current_thread() };
|
let thread = unsafe { current_thread() };
|
||||||
thread.vm.lock().push(
|
thread.vm.lock().push(
|
||||||
area.start_vaddr,
|
area.start_vaddr,
|
||||||
area.end_vaddr,
|
area.end_vaddr,
|
||||||
|
@ -22,7 +22,7 @@ impl FileLike {
|
|||||||
let len = match self {
|
let len = match self {
|
||||||
FileLike::File(file) => file.read(buf)?,
|
FileLike::File(file) => file.read(buf)?,
|
||||||
FileLike::Socket(socket) => socket.read(buf).0?,
|
FileLike::Socket(socket) => socket.read(buf).0?,
|
||||||
FileLike::EpollInstance(instance) => {
|
FileLike::EpollInstance(_) => {
|
||||||
return Err(SysError::ENOSYS);
|
return Err(SysError::ENOSYS);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -32,7 +32,7 @@ impl FileLike {
|
|||||||
let len = match self {
|
let len = match self {
|
||||||
FileLike::File(file) => file.write(buf)?,
|
FileLike::File(file) => file.write(buf)?,
|
||||||
FileLike::Socket(socket) => socket.write(buf, None)?,
|
FileLike::Socket(socket) => socket.write(buf, None)?,
|
||||||
FileLike::EpollInstance(instance) => {
|
FileLike::EpollInstance(_) => {
|
||||||
return Err(SysError::ENOSYS);
|
return Err(SysError::ENOSYS);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -49,7 +49,7 @@ impl FileLike {
|
|||||||
FileLike::Socket(socket) => {
|
FileLike::Socket(socket) => {
|
||||||
socket.ioctl(request, arg1, arg2, arg3)?;
|
socket.ioctl(request, arg1, arg2, arg3)?;
|
||||||
}
|
}
|
||||||
FileLike::EpollInstance(instance) => {
|
FileLike::EpollInstance(_) => {
|
||||||
return Err(SysError::ENOSYS);
|
return Err(SysError::ENOSYS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ impl FileLike {
|
|||||||
let (read, write, error) = socket.poll();
|
let (read, write, error) = socket.poll();
|
||||||
PollStatus { read, write, error }
|
PollStatus { read, write, error }
|
||||||
}
|
}
|
||||||
FileLike::EpollInstance(instance) => {
|
FileLike::EpollInstance(_) => {
|
||||||
return Err(SysError::ENOSYS);
|
return Err(SysError::ENOSYS);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -80,10 +80,10 @@ impl FileLike {
|
|||||||
pub fn fcntl(&mut self, cmd: usize, arg: usize) -> SysResult {
|
pub fn fcntl(&mut self, cmd: usize, arg: usize) -> SysResult {
|
||||||
match self {
|
match self {
|
||||||
FileLike::File(file) => file.fcntl(cmd, arg)?,
|
FileLike::File(file) => file.fcntl(cmd, arg)?,
|
||||||
FileLike::Socket(socket) => {
|
FileLike::Socket(_) => {
|
||||||
//TODO
|
//TODO
|
||||||
}
|
}
|
||||||
FileLike::EpollInstance(instance) => {}
|
FileLike::EpollInstance(_) => {}
|
||||||
}
|
}
|
||||||
Ok(0)
|
Ok(0)
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ impl fmt::Debug for FileLike {
|
|||||||
match self {
|
match self {
|
||||||
FileLike::File(file) => write!(f, "File({:?})", file),
|
FileLike::File(file) => write!(f, "File({:?})", file),
|
||||||
FileLike::Socket(socket) => write!(f, "Socket({:?})", socket),
|
FileLike::Socket(socket) => write!(f, "Socket({:?})", socket),
|
||||||
FileLike::EpollInstance(instance) => write!(f, "EpollInstance()"),
|
FileLike::EpollInstance(_) => write!(f, "EpollInstance()"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// for IOR and IOW:
|
// for IOR and IOW:
|
||||||
// 32bits total, command in lower 16bits, size of the parameter structure in the lower 14 bits of the upper 16 bits
|
// 32bits total, command in lower 16bits, size of the parameter structure in the lower 14 bits of the upper 16 bits
|
||||||
// higher 2 bits: 01 = write, 10 = read
|
// higher 2 bits: 01 = write, 10 = read
|
||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
#[cfg(not(target_arch = "mips"))]
|
#[cfg(not(target_arch = "mips"))]
|
||||||
pub const TCGETS: usize = 0x5401;
|
pub const TCGETS: usize = 0x5401;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
use alloc::{sync::Arc, vec::Vec};
|
use alloc::{sync::Arc, vec::Vec};
|
||||||
|
|
||||||
use rcore_fs::dev::block_cache::BlockCache;
|
|
||||||
use rcore_fs::vfs::*;
|
use rcore_fs::vfs::*;
|
||||||
use rcore_fs_devfs::{
|
use rcore_fs_devfs::{
|
||||||
special::{NullINode, ZeroINode},
|
special::{NullINode, ZeroINode},
|
||||||
@ -11,7 +10,6 @@ use rcore_fs_ramfs::RamFS;
|
|||||||
use rcore_fs_sfs::SimpleFileSystem;
|
use rcore_fs_sfs::SimpleFileSystem;
|
||||||
|
|
||||||
use self::devfs::{Fbdev, RandomINode};
|
use self::devfs::{Fbdev, RandomINode};
|
||||||
use crate::drivers::BlockDriver;
|
|
||||||
|
|
||||||
pub use self::devfs::{STDIN, STDOUT};
|
pub use self::devfs::{STDIN, STDOUT};
|
||||||
pub use self::file::*;
|
pub use self::file::*;
|
||||||
@ -50,6 +48,8 @@ lazy_static! {
|
|||||||
let device = {
|
let device = {
|
||||||
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64", target_arch = "x86_64"))]
|
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64", target_arch = "x86_64"))]
|
||||||
{
|
{
|
||||||
|
use crate::drivers::BlockDriver;
|
||||||
|
use rcore_fs::dev::block_cache::BlockCache;
|
||||||
let driver = BlockDriver(
|
let driver = BlockDriver(
|
||||||
crate::drivers::BLK_DRIVERS
|
crate::drivers::BLK_DRIVERS
|
||||||
.read().iter()
|
.read().iter()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//! Implement INode for Pipe
|
//! Implement INode for Pipe
|
||||||
|
|
||||||
use alloc::{collections::vec_deque::VecDeque, string::String, sync::Arc};
|
use alloc::{collections::vec_deque::VecDeque, sync::Arc};
|
||||||
use core::any::Any;
|
use core::any::Any;
|
||||||
|
|
||||||
use rcore_fs::vfs::*;
|
use rcore_fs::vfs::*;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//! Pseudo file system INode
|
//! Pseudo file system INode
|
||||||
|
|
||||||
use alloc::{string::String, sync::Arc, vec::Vec};
|
use alloc::vec::Vec;
|
||||||
use core::any::Any;
|
use core::any::Any;
|
||||||
|
|
||||||
use rcore_fs::vfs::*;
|
use rcore_fs::vfs::*;
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
use crate::sync::Semaphore;
|
use crate::sync::Semaphore;
|
||||||
use crate::sync::SpinLock as Mutex;
|
use alloc::{collections::BTreeMap, sync::Arc, sync::Weak, vec::Vec};
|
||||||
use alloc::{boxed::Box, collections::BTreeMap, string::String, sync::Arc, sync::Weak, vec::Vec};
|
|
||||||
use core::ops::Index;
|
use core::ops::Index;
|
||||||
use spin::RwLock;
|
use spin::RwLock;
|
||||||
|
|
||||||
/// A System V semaphore set
|
/// A System V semaphore set
|
||||||
pub struct SemArray {
|
pub struct SemArray {
|
||||||
key: usize,
|
_key: usize,
|
||||||
sems: Vec<Semaphore>,
|
sems: Vec<Semaphore>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,12 +34,12 @@ impl SemArray {
|
|||||||
}
|
}
|
||||||
// not found, create one
|
// not found, create one
|
||||||
let mut semaphores = Vec::new();
|
let mut semaphores = Vec::new();
|
||||||
for i in 0..nsems {
|
for _ in 0..nsems {
|
||||||
semaphores.push(Semaphore::new(0));
|
semaphores.push(Semaphore::new(0));
|
||||||
}
|
}
|
||||||
// insert to global map
|
// insert to global map
|
||||||
let array = Arc::new(SemArray {
|
let array = Arc::new(SemArray {
|
||||||
key,
|
_key: key,
|
||||||
sems: semaphores,
|
sems: semaphores,
|
||||||
});
|
});
|
||||||
key2sem.insert(key, Arc::downgrade(&array));
|
key2sem.insert(key, Arc::downgrade(&array));
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::lkm::manager::ModuleManager;
|
|
||||||
use crate::lkm::structs::LoadedModule;
|
use crate::lkm::structs::LoadedModule;
|
||||||
use alloc::boxed::Box;
|
|
||||||
use alloc::string::String;
|
use alloc::string::String;
|
||||||
use alloc::sync::Arc;
|
use alloc::sync::Arc;
|
||||||
use core::alloc::{GlobalAlloc, Layout};
|
use core::alloc::{GlobalAlloc, Layout};
|
||||||
@ -10,7 +8,7 @@ use core::slice::from_raw_parts;
|
|||||||
pub fn get_module(this_module: usize) -> &'static mut LoadedModule {
|
pub fn get_module(this_module: usize) -> &'static mut LoadedModule {
|
||||||
unsafe {
|
unsafe {
|
||||||
let ptr = this_module as *mut LoadedModule;
|
let ptr = this_module as *mut LoadedModule;
|
||||||
&mut (*ptr) as (&'static mut LoadedModule)
|
&mut (*ptr) as &'static mut LoadedModule
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +79,6 @@ pub extern "C" fn lkm_api_add_kernel_symbols(start: usize, end: usize) {
|
|||||||
let symbols = unsafe { from_utf8(from_raw_parts(start as *const u8, length)) }.unwrap();
|
let symbols = unsafe { from_utf8(from_raw_parts(start as *const u8, length)) }.unwrap();
|
||||||
let global_lkmm = &LKM_MANAGER;
|
let global_lkmm = &LKM_MANAGER;
|
||||||
let mut locked_lkmm = global_lkmm.lock();
|
let mut locked_lkmm = global_lkmm.lock();
|
||||||
let mut lkmm = locked_lkmm.as_mut().unwrap();
|
let lkmm = locked_lkmm.as_mut().unwrap();
|
||||||
lkmm.init_kernel_symbols(symbols);
|
lkmm.init_kernel_symbols(symbols);
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
// Simple kernel memory set for kernel virtual memory
|
// Simple kernel memory set for kernel virtual memory
|
||||||
use crate::arch::paging::PageTableImpl;
|
use crate::arch::paging::PageTableImpl;
|
||||||
use crate::consts::*;
|
|
||||||
use crate::memory::GlobalFrameAlloc;
|
use crate::memory::GlobalFrameAlloc;
|
||||||
use crate::sync::SpinLock as Mutex;
|
use crate::sync::SpinLock as Mutex;
|
||||||
use alloc::vec::*;
|
use alloc::vec::*;
|
||||||
use buddy_system_allocator::*;
|
|
||||||
use core::alloc::Layout;
|
|
||||||
use core::mem::ManuallyDrop;
|
use core::mem::ManuallyDrop;
|
||||||
use core::ops::DerefMut;
|
use core::ops::DerefMut;
|
||||||
use core::ptr::NonNull;
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use rcore_memory::memory_set::handler::{ByFrame, MemoryHandler};
|
use rcore_memory::memory_set::handler::{ByFrame, MemoryHandler};
|
||||||
use rcore_memory::memory_set::MemoryAttr;
|
use rcore_memory::memory_set::MemoryAttr;
|
||||||
@ -38,14 +34,14 @@ impl MemorySpaceManager for LinearManager {
|
|||||||
LinearManager { last_page: 0 }
|
LinearManager { last_page: 0 }
|
||||||
}
|
}
|
||||||
fn alloc(&mut self, size: usize) -> Option<(usize, usize)> {
|
fn alloc(&mut self, size: usize) -> Option<(usize, usize)> {
|
||||||
let mut required_pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
|
let required_pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
|
||||||
|
|
||||||
let current = self.last_page * PAGE_SIZE + KSEG2_START;
|
let current = self.last_page * PAGE_SIZE + KSEG2_START;
|
||||||
self.last_page += required_pages;
|
self.last_page += required_pages;
|
||||||
Some((current, required_pages * PAGE_SIZE))
|
Some((current, required_pages * PAGE_SIZE))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn free(&mut self, (addr, size): (usize, usize)) {
|
fn free(&mut self, (_addr, _size): (usize, usize)) {
|
||||||
//Do nothing.
|
//Do nothing.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,7 +95,7 @@ impl VirtualSpace {
|
|||||||
|
|
||||||
impl Drop for VirtualSpace {
|
impl Drop for VirtualSpace {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
for mut v in self.areas.iter_mut() {
|
for v in self.areas.iter_mut() {
|
||||||
v.unmap(self.allocator, &mut self.page_allocator);
|
v.unmap(self.allocator, &mut self.page_allocator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,7 +104,7 @@ impl Drop for VirtualSpace {
|
|||||||
pub struct VirtualArea {
|
pub struct VirtualArea {
|
||||||
start: usize,
|
start: usize,
|
||||||
end: usize,
|
end: usize,
|
||||||
attr: MemoryAttr,
|
_attr: MemoryAttr,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VirtualArea {
|
impl VirtualArea {
|
||||||
@ -119,7 +115,7 @@ impl VirtualArea {
|
|||||||
parent: &mut VirtualSpace,
|
parent: &mut VirtualSpace,
|
||||||
) -> VirtualArea {
|
) -> VirtualArea {
|
||||||
let aligned_start_addr = page_addr - page_addr % PAGE_SIZE;
|
let aligned_start_addr = page_addr - page_addr % PAGE_SIZE;
|
||||||
let mut aligned_end = (page_addr + size + PAGE_SIZE - 1);
|
let mut aligned_end = page_addr + size + PAGE_SIZE - 1;
|
||||||
aligned_end = aligned_end - aligned_end % PAGE_SIZE;
|
aligned_end = aligned_end - aligned_end % PAGE_SIZE;
|
||||||
let lock = parent.allocator.lock();
|
let lock = parent.allocator.lock();
|
||||||
let mut active_pt = lock.kernel_table();
|
let mut active_pt = lock.kernel_table();
|
||||||
@ -132,7 +128,7 @@ impl VirtualArea {
|
|||||||
VirtualArea {
|
VirtualArea {
|
||||||
start: aligned_start_addr,
|
start: aligned_start_addr,
|
||||||
end: aligned_end,
|
end: aligned_end,
|
||||||
attr: attr.clone(),
|
_attr: attr.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn unmap(&mut self, allocator: &LockedVMM, parent: &mut ByFrame<GlobalFrameAlloc>) {
|
pub fn unmap(&mut self, allocator: &LockedVMM, parent: &mut ByFrame<GlobalFrameAlloc>) {
|
||||||
|
@ -2,36 +2,26 @@ use super::api::*;
|
|||||||
use super::const_reloc as loader;
|
use super::const_reloc as loader;
|
||||||
use super::kernelvm::*;
|
use super::kernelvm::*;
|
||||||
use super::structs::*;
|
use super::structs::*;
|
||||||
use crate::consts::*;
|
|
||||||
use crate::lkm::structs::ModuleState::{Ready, Unloading};
|
use crate::lkm::structs::ModuleState::{Ready, Unloading};
|
||||||
use crate::memory::GlobalFrameAlloc;
|
use crate::sync::SpinLock as Mutex;
|
||||||
use crate::sync::{Condvar, SpinLock as Mutex};
|
|
||||||
use crate::syscall::SysError::*;
|
use crate::syscall::SysError::*;
|
||||||
use crate::syscall::SysResult;
|
use crate::syscall::SysResult;
|
||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
use alloc::collections::btree_map::BTreeMap;
|
use alloc::collections::btree_map::BTreeMap;
|
||||||
use alloc::prelude::*;
|
|
||||||
use alloc::string::*;
|
use alloc::string::*;
|
||||||
use alloc::sync::Arc;
|
use alloc::sync::Arc;
|
||||||
use alloc::vec::*;
|
use alloc::vec::*;
|
||||||
use core::borrow::BorrowMut;
|
|
||||||
use core::mem::transmute;
|
use core::mem::transmute;
|
||||||
use core::slice;
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use rcore_memory::memory_set::handler::{ByFrame, MemoryHandler};
|
|
||||||
use rcore_memory::memory_set::MemoryAttr;
|
use rcore_memory::memory_set::MemoryAttr;
|
||||||
use rcore_memory::{Page, PAGE_SIZE};
|
use rcore_memory::PAGE_SIZE;
|
||||||
use xmas_elf::dynamic::Tag;
|
use xmas_elf::dynamic::Tag;
|
||||||
use xmas_elf::program::Type::Load;
|
use xmas_elf::program::Type::Load;
|
||||||
use xmas_elf::sections::SectionData;
|
use xmas_elf::sections::SectionData;
|
||||||
use xmas_elf::sections::SectionData::{DynSymbolTable64, Dynamic64, Undefined};
|
use xmas_elf::sections::SectionData::{DynSymbolTable64, Dynamic64, Undefined};
|
||||||
use xmas_elf::symbol_table::DynEntry64;
|
use xmas_elf::symbol_table::DynEntry64;
|
||||||
use xmas_elf::symbol_table::Entry;
|
use xmas_elf::symbol_table::Entry;
|
||||||
use xmas_elf::{
|
use xmas_elf::{header, ElfFile};
|
||||||
header,
|
|
||||||
program::{Flags, Type},
|
|
||||||
ElfFile,
|
|
||||||
};
|
|
||||||
// The symbol data table.
|
// The symbol data table.
|
||||||
global_asm!(include_str!("symbol_table.asm"));
|
global_asm!(include_str!("symbol_table.asm"));
|
||||||
|
|
||||||
@ -96,15 +86,15 @@ impl ModuleManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
use compression::prelude::*;
|
use compression::prelude::*;
|
||||||
let zipped_symbols =
|
let zipped_symbols = unsafe {
|
||||||
unsafe { slice::from_raw_parts(symbol_table_start as *const u8, symbol_table_len) }
|
core::slice::from_raw_parts(symbol_table_start as *const u8, symbol_table_len)
|
||||||
.to_vec();
|
}
|
||||||
|
.to_vec();
|
||||||
|
|
||||||
let real_symbols = zipped_symbols
|
let real_symbols = zipped_symbols
|
||||||
.decode(&mut GZipDecoder::new())
|
.decode(&mut GZipDecoder::new())
|
||||||
.collect::<Result<Vec<_>, _>>()
|
.collect::<Result<Vec<_>, _>>()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
use core::slice;
|
|
||||||
use core::str::from_utf8;
|
use core::str::from_utf8;
|
||||||
self.init_kernel_symbols(from_utf8(&real_symbols).unwrap());
|
self.init_kernel_symbols(from_utf8(&real_symbols).unwrap());
|
||||||
}
|
}
|
||||||
@ -113,7 +103,7 @@ impl ModuleManager {
|
|||||||
for l in lines.into_iter() {
|
for l in lines.into_iter() {
|
||||||
let mut words = l.split_whitespace();
|
let mut words = l.split_whitespace();
|
||||||
let address = words.next().unwrap();
|
let address = words.next().unwrap();
|
||||||
let stype = words.next().unwrap();
|
let _stype = words.next().unwrap();
|
||||||
let name = words.next().unwrap();
|
let name = words.next().unwrap();
|
||||||
// Simply add the symbol into stub.
|
// Simply add the symbol into stub.
|
||||||
self.stub_symbols.insert(
|
self.stub_symbols.insert(
|
||||||
@ -170,7 +160,7 @@ impl ModuleManager {
|
|||||||
Some(base + (selected_symbol.value() as usize))
|
Some(base + (selected_symbol.value() as usize))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn init_module(&mut self, module_image: &[u8], param_values: &str) -> SysResult {
|
pub fn init_module(&mut self, module_image: &[u8], _param_values: &str) -> SysResult {
|
||||||
let elf = ElfFile::new(module_image).expect("[LKM] failed to read elf");
|
let elf = ElfFile::new(module_image).expect("[LKM] failed to read elf");
|
||||||
let is32 = match elf.header.pt2 {
|
let is32 = match elf.header.pt2 {
|
||||||
header::HeaderPt2::Header32(_) => true,
|
header::HeaderPt2::Header32(_) => true,
|
||||||
@ -299,7 +289,7 @@ impl ModuleManager {
|
|||||||
if flags.is_execute() {
|
if flags.is_execute() {
|
||||||
attr = attr.execute();
|
attr = attr.execute();
|
||||||
}
|
}
|
||||||
let area_ref = vspace_ref.add_area(prog_start_addr, prog_end_addr, &attr);
|
let _area_ref = vspace_ref.add_area(prog_start_addr, prog_end_addr, &attr);
|
||||||
//self.vallocator.map_pages(prog_start_addr, prog_end_addr, &attr);
|
//self.vallocator.map_pages(prog_start_addr, prog_end_addr, &attr);
|
||||||
//No need to flush TLB.
|
//No need to flush TLB.
|
||||||
let target = unsafe {
|
let target = unsafe {
|
||||||
@ -497,7 +487,7 @@ impl ModuleManager {
|
|||||||
fn reloc_symbols(
|
fn reloc_symbols(
|
||||||
&mut self,
|
&mut self,
|
||||||
elf: &ElfFile,
|
elf: &ElfFile,
|
||||||
(start, total_size, single_size): (usize, usize, usize),
|
(start, total_size, _single_size): (usize, usize, usize),
|
||||||
base: usize,
|
base: usize,
|
||||||
dynsym: &[DynEntry64],
|
dynsym: &[DynEntry64],
|
||||||
this_module: usize,
|
this_module: usize,
|
||||||
@ -511,8 +501,8 @@ impl ModuleManager {
|
|||||||
match s.get_data(elf).unwrap() {
|
match s.get_data(elf).unwrap() {
|
||||||
SectionData::Rela64(rela_items) => {
|
SectionData::Rela64(rela_items) => {
|
||||||
for item in rela_items.iter() {
|
for item in rela_items.iter() {
|
||||||
let mut addend = item.get_addend() as usize;
|
let addend = item.get_addend() as usize;
|
||||||
let mut reloc_addr = item.get_offset() as usize;
|
let reloc_addr = item.get_offset() as usize;
|
||||||
let sti = item.get_symbol_table_index() as usize;
|
let sti = item.get_symbol_table_index() as usize;
|
||||||
let itype = item.get_type() as usize;
|
let itype = item.get_type() as usize;
|
||||||
self.relocate_single_symbol(
|
self.relocate_single_symbol(
|
||||||
@ -529,8 +519,8 @@ impl ModuleManager {
|
|||||||
}
|
}
|
||||||
SectionData::Rel64(rel_items) => {
|
SectionData::Rel64(rel_items) => {
|
||||||
for item in rel_items.iter() {
|
for item in rel_items.iter() {
|
||||||
let mut addend = 0 as usize;
|
let addend = 0 as usize;
|
||||||
let mut reloc_addr = item.get_offset() as usize;
|
let reloc_addr = item.get_offset() as usize;
|
||||||
let sti = item.get_symbol_table_index() as usize;
|
let sti = item.get_symbol_table_index() as usize;
|
||||||
let itype = item.get_type() as usize;
|
let itype = item.get_type() as usize;
|
||||||
self.relocate_single_symbol(
|
self.relocate_single_symbol(
|
||||||
@ -554,7 +544,7 @@ impl ModuleManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn delete_module(&mut self, name: &str, flags: u32) -> SysResult {
|
pub fn delete_module(&mut self, name: &str, _flags: u32) -> SysResult {
|
||||||
//unimplemented!("[LKM] You can't plug out what's INSIDE you, RIGHT?");
|
//unimplemented!("[LKM] You can't plug out what's INSIDE you, RIGHT?");
|
||||||
|
|
||||||
info!("[LKM] now you can plug out a kernel module!");
|
info!("[LKM] now you can plug out a kernel module!");
|
||||||
@ -589,7 +579,7 @@ impl ModuleManager {
|
|||||||
}
|
}
|
||||||
drop(mod_lock);
|
drop(mod_lock);
|
||||||
|
|
||||||
let my_box = self.loaded_modules.remove(i);
|
let _my_box = self.loaded_modules.remove(i);
|
||||||
unsafe {
|
unsafe {
|
||||||
LKM_MANAGER.force_unlock();
|
LKM_MANAGER.force_unlock();
|
||||||
}
|
}
|
||||||
@ -607,7 +597,7 @@ impl ModuleManager {
|
|||||||
pub fn with<T>(f: impl FnOnce(&mut ModuleManager) -> T) -> T {
|
pub fn with<T>(f: impl FnOnce(&mut ModuleManager) -> T) -> T {
|
||||||
let global_lkmm: &Mutex<Option<ModuleManager>> = &LKM_MANAGER;
|
let global_lkmm: &Mutex<Option<ModuleManager>> = &LKM_MANAGER;
|
||||||
let mut locked_lkmm = global_lkmm.lock();
|
let mut locked_lkmm = global_lkmm.lock();
|
||||||
let mut lkmm = locked_lkmm.as_mut().unwrap();
|
let lkmm = locked_lkmm.as_mut().unwrap();
|
||||||
f(lkmm)
|
f(lkmm)
|
||||||
}
|
}
|
||||||
pub fn init() {
|
pub fn init() {
|
||||||
|
@ -155,7 +155,7 @@ pub fn enlarge_heap(heap: &mut Heap) {
|
|||||||
let mut addrs = [(0, 0); 32];
|
let mut addrs = [(0, 0); 32];
|
||||||
let mut addr_len = 0;
|
let mut addr_len = 0;
|
||||||
let va_offset = PHYSICAL_MEMORY_OFFSET;
|
let va_offset = PHYSICAL_MEMORY_OFFSET;
|
||||||
for i in 0..16384 {
|
for _ in 0..16384 {
|
||||||
let page = alloc_frame().unwrap();
|
let page = alloc_frame().unwrap();
|
||||||
let va = va_offset + page;
|
let va = va_offset + page;
|
||||||
if addr_len > 0 {
|
if addr_len > 0 {
|
||||||
|
@ -197,7 +197,7 @@ impl Socket for TcpSocketState {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write(&self, data: &[u8], sendto_endpoint: Option<Endpoint>) -> SysResult {
|
fn write(&self, data: &[u8], _sendto_endpoint: Option<Endpoint>) -> SysResult {
|
||||||
let mut sockets = SOCKETS.lock();
|
let mut sockets = SOCKETS.lock();
|
||||||
let mut socket = sockets.get::<TcpSocket>(self.handle.0);
|
let mut socket = sockets.get::<TcpSocket>(self.handle.0);
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ impl Socket for TcpSocketState {
|
|||||||
poll_ifaces();
|
poll_ifaces();
|
||||||
Ok(size)
|
Ok(size)
|
||||||
}
|
}
|
||||||
Err(err) => Err(SysError::ENOBUFS),
|
Err(_) => Err(SysError::ENOBUFS),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Err(SysError::ENOBUFS)
|
Err(SysError::ENOBUFS)
|
||||||
@ -480,7 +480,7 @@ impl Socket for UdpSocketState {
|
|||||||
poll_ifaces();
|
poll_ifaces();
|
||||||
Ok(data.len())
|
Ok(data.len())
|
||||||
}
|
}
|
||||||
Err(err) => Err(SysError::ENOBUFS),
|
Err(_) => Err(SysError::ENOBUFS),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Err(SysError::ENOBUFS)
|
Err(SysError::ENOBUFS)
|
||||||
@ -523,7 +523,7 @@ impl Socket for UdpSocketState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ioctl(&mut self, request: usize, arg1: usize, arg2: usize, arg3: usize) -> SysResult {
|
fn ioctl(&mut self, request: usize, arg1: usize, _arg2: usize, _arg3: usize) -> SysResult {
|
||||||
match request {
|
match request {
|
||||||
// SIOCGARP
|
// SIOCGARP
|
||||||
0x8954 => {
|
0x8954 => {
|
||||||
@ -710,7 +710,7 @@ impl PacketSocketState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Socket for PacketSocketState {
|
impl Socket for PacketSocketState {
|
||||||
fn read(&self, data: &mut [u8]) -> (SysResult, Endpoint) {
|
fn read(&self, _data: &mut [u8]) -> (SysResult, Endpoint) {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ pub extern "C" fn server(_arg: usize) -> ! {
|
|||||||
|
|
||||||
if socket.can_recv() {
|
if socket.can_recv() {
|
||||||
let mut data = [0u8; 2048];
|
let mut data = [0u8; 2048];
|
||||||
let size = socket.recv_slice(&mut data).unwrap();
|
let _size = socket.recv_slice(&mut data).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ use crate::process::thread_manager;
|
|||||||
use core::mem::MaybeUninit;
|
use core::mem::MaybeUninit;
|
||||||
use rcore_fs::vfs::INode;
|
use rcore_fs::vfs::INode;
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub struct Thread {
|
pub struct Thread {
|
||||||
context: Context,
|
context: Context,
|
||||||
kstack: KernelStack,
|
kstack: KernelStack,
|
||||||
@ -102,10 +103,11 @@ impl rcore_thread::Context for Thread {
|
|||||||
impl Thread {
|
impl Thread {
|
||||||
/// Make a struct for the init thread
|
/// Make a struct for the init thread
|
||||||
pub unsafe fn new_init() -> Box<Thread> {
|
pub unsafe fn new_init() -> Box<Thread> {
|
||||||
|
let zero = MaybeUninit::<Thread>::zeroed();
|
||||||
Box::new(Thread {
|
Box::new(Thread {
|
||||||
context: Context::null(),
|
context: Context::null(),
|
||||||
// safety: other fields will never be used
|
// safety: other fields will never be used
|
||||||
..core::mem::MaybeUninit::zeroed().assume_init()
|
..zero.assume_init()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,8 +145,8 @@ impl Thread {
|
|||||||
/// Return `(MemorySet, entry_point, ustack_top)`
|
/// Return `(MemorySet, entry_point, ustack_top)`
|
||||||
pub fn new_user_vm(
|
pub fn new_user_vm(
|
||||||
inode: &Arc<dyn INode>,
|
inode: &Arc<dyn INode>,
|
||||||
exec_path: &str,
|
_exec_path: &str,
|
||||||
mut args: Vec<String>,
|
args: Vec<String>,
|
||||||
envs: Vec<String>,
|
envs: Vec<String>,
|
||||||
) -> Result<(MemorySet, usize, usize), &'static str> {
|
) -> Result<(MemorySet, usize, usize), &'static str> {
|
||||||
// Read ELF header
|
// Read ELF header
|
||||||
@ -385,12 +387,7 @@ impl Process {
|
|||||||
let mut process_table = PROCESSES.write();
|
let mut process_table = PROCESSES.write();
|
||||||
|
|
||||||
// assign pid
|
// assign pid
|
||||||
let pid = (0..)
|
let pid = (0..).find(|i| process_table.get(i).is_none()).unwrap();
|
||||||
.find(|i| match process_table.get(i) {
|
|
||||||
Some(p) => false,
|
|
||||||
_ => true,
|
|
||||||
})
|
|
||||||
.unwrap();
|
|
||||||
self.pid = Pid(pid);
|
self.pid = Pid(pid);
|
||||||
|
|
||||||
// put to process table
|
// put to process table
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::process::thread_manager;
|
||||||
use crate::process::Process;
|
use crate::process::Process;
|
||||||
use crate::process::{current_thread, thread_manager};
|
|
||||||
use crate::thread;
|
use crate::thread;
|
||||||
use alloc::collections::VecDeque;
|
use alloc::collections::VecDeque;
|
||||||
use alloc::sync::Arc;
|
use alloc::sync::Arc;
|
||||||
@ -44,7 +44,7 @@ impl Condvar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Wait for condvar until condition() returns Some
|
/// Wait for condvar until condition() returns Some
|
||||||
pub fn wait_event<T>(condvar: &Condvar, mut condition: impl FnMut() -> Option<T>) -> T {
|
pub fn wait_event<T>(condvar: &Condvar, condition: impl FnMut() -> Option<T>) -> T {
|
||||||
Self::wait_events(&[condvar], condition)
|
Self::wait_events(&[condvar], condition)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ impl Condvar {
|
|||||||
let mut locks = Vec::with_capacity(condvars.len());
|
let mut locks = Vec::with_capacity(condvars.len());
|
||||||
loop {
|
loop {
|
||||||
for condvar in condvars {
|
for condvar in condvars {
|
||||||
let mut lock = condvar.wait_queue.lock();
|
let lock = condvar.wait_queue.lock();
|
||||||
locks.push(lock);
|
locks.push(lock);
|
||||||
}
|
}
|
||||||
thread_manager().sleep(tid, 0);
|
thread_manager().sleep(tid, 0);
|
||||||
@ -162,13 +162,13 @@ impl Condvar {
|
|||||||
let epoll_list = self.epoll_queue.lock();
|
let epoll_list = self.epoll_queue.lock();
|
||||||
for ist in epoll_list.iter() {
|
for ist in epoll_list.iter() {
|
||||||
if thread.id() == ist.tid {
|
if thread.id() == ist.tid {
|
||||||
let mut proc = ist.proc.lock();
|
let proc = ist.proc.lock();
|
||||||
match proc.get_epoll_instance(ist.epfd) {
|
match proc.get_epoll_instance(ist.epfd) {
|
||||||
Ok(instacne) => {
|
Ok(instacne) => {
|
||||||
let mut readylist = instacne.readyList.lock();
|
let mut ready_list = instacne.ready_list.lock();
|
||||||
readylist.insert(ist.fd);
|
ready_list.insert(ist.fd);
|
||||||
}
|
}
|
||||||
Err(r) => {
|
Err(_) => {
|
||||||
panic!("epoll instance not exist");
|
panic!("epoll instance not exist");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ impl Semaphore {
|
|||||||
|
|
||||||
/// Get the current count
|
/// Get the current count
|
||||||
pub fn get(&self) -> isize {
|
pub fn get(&self) -> isize {
|
||||||
let mut count = self.lock.lock();
|
let count = self.lock.lock();
|
||||||
*count
|
*count
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
//! Custom nonstandard syscalls
|
//! Custom nonstandard syscalls
|
||||||
use super::*;
|
use super::*;
|
||||||
use rcore_memory::memory_set::handler::Linear;
|
|
||||||
use rcore_memory::memory_set::MemoryAttr;
|
|
||||||
|
|
||||||
impl Syscall<'_> {
|
impl Syscall<'_> {
|
||||||
/// Allocate this PCI device to user space
|
/// Allocate this PCI device to user space
|
||||||
@ -9,6 +7,9 @@ impl Syscall<'_> {
|
|||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
pub fn sys_map_pci_device(&mut self, vendor: usize, product: usize) -> SysResult {
|
pub fn sys_map_pci_device(&mut self, vendor: usize, product: usize) -> SysResult {
|
||||||
use crate::drivers::bus::pci;
|
use crate::drivers::bus::pci;
|
||||||
|
use rcore_memory::memory_set::handler::Linear;
|
||||||
|
use rcore_memory::memory_set::MemoryAttr;
|
||||||
|
|
||||||
info!(
|
info!(
|
||||||
"map_pci_device: vendor: {:x}, product: {:x}",
|
"map_pci_device: vendor: {:x}, product: {:x}",
|
||||||
vendor, product
|
vendor, product
|
||||||
@ -35,7 +36,7 @@ impl Syscall<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_arch = "x86_64"))]
|
#[cfg(not(target_arch = "x86_64"))]
|
||||||
pub fn sys_map_pci_device(&mut self, vendor: usize, product: usize) -> SysResult {
|
pub fn sys_map_pci_device(&mut self, _vendor: usize, _product: usize) -> SysResult {
|
||||||
Err(SysError::ENOSYS)
|
Err(SysError::ENOSYS)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
//! Syscalls for file system
|
//! Syscalls for file system
|
||||||
|
|
||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use core::cell::UnsafeCell;
|
use core::cell::UnsafeCell;
|
||||||
use core::cmp::min;
|
use core::cmp::min;
|
||||||
use core::mem::size_of;
|
use core::mem::size_of;
|
||||||
@ -8,18 +11,14 @@ use rcore_fs::vfs::Timespec;
|
|||||||
use crate::drivers::SOCKET_ACTIVITY;
|
use crate::drivers::SOCKET_ACTIVITY;
|
||||||
use crate::fs::*;
|
use crate::fs::*;
|
||||||
use crate::memory::MemorySet;
|
use crate::memory::MemorySet;
|
||||||
use crate::sync::{Condvar, SpinNoIrqLock};
|
use crate::sync::Condvar;
|
||||||
use crate::trap::TICK_ACTIVITY;
|
use crate::trap::TICK_ACTIVITY;
|
||||||
use alloc::{collections::BTreeMap, collections::BTreeSet};
|
|
||||||
|
|
||||||
use bitvec::prelude::{BitSlice, BitVec, LittleEndian};
|
use bitvec::prelude::{BitSlice, BitVec, Lsb0};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::fs::epoll::EpollInstance;
|
use crate::fs::epoll::EpollInstance;
|
||||||
use crate::net::server;
|
|
||||||
use crate::process::Process;
|
use crate::process::Process;
|
||||||
use alloc::collections::VecDeque;
|
|
||||||
use bitflags::_core::task::Poll;
|
|
||||||
use rcore_fs::vfs::PollStatus;
|
use rcore_fs::vfs::PollStatus;
|
||||||
|
|
||||||
impl Syscall<'_> {
|
impl Syscall<'_> {
|
||||||
@ -106,7 +105,7 @@ impl Syscall<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check whether the fds is valid and is owned by this process
|
// check whether the fds is valid and is owned by this process
|
||||||
let mut condvars = alloc::vec![&(*TICK_ACTIVITY), &STDIN.pushed, &(*SOCKET_ACTIVITY)];
|
let condvars = alloc::vec![&(*TICK_ACTIVITY), &STDIN.pushed, &(*SOCKET_ACTIVITY)];
|
||||||
|
|
||||||
let polls = unsafe { self.vm().check_write_array(ufds, nfds)? };
|
let polls = unsafe { self.vm().check_write_array(ufds, nfds)? };
|
||||||
|
|
||||||
@ -198,7 +197,7 @@ impl Syscall<'_> {
|
|||||||
1 << 31
|
1 << 31
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut condvars = alloc::vec![&(*TICK_ACTIVITY), &STDIN.pushed, &(*SOCKET_ACTIVITY)];
|
let condvars = alloc::vec![&(*TICK_ACTIVITY), &STDIN.pushed, &(*SOCKET_ACTIVITY)];
|
||||||
|
|
||||||
// for debugging
|
// for debugging
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
@ -268,8 +267,8 @@ impl Syscall<'_> {
|
|||||||
pub fn sys_epoll_create1(&mut self, flags: usize) -> SysResult {
|
pub fn sys_epoll_create1(&mut self, flags: usize) -> SysResult {
|
||||||
info!("epoll_create1: flags: {:?}", flags);
|
info!("epoll_create1: flags: {:?}", flags);
|
||||||
let mut proc = self.process();
|
let mut proc = self.process();
|
||||||
let epollInstance = EpollInstance::new(flags);
|
let epoll_instance = EpollInstance::new(flags);
|
||||||
let fd = proc.add_file(FileLike::EpollInstance(epollInstance));
|
let fd = proc.add_file(FileLike::EpollInstance(epoll_instance));
|
||||||
Ok(fd)
|
Ok(fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,14 +291,14 @@ impl Syscall<'_> {
|
|||||||
return Err(SysError::EPERM);
|
return Err(SysError::EPERM);
|
||||||
}
|
}
|
||||||
|
|
||||||
let epollInstance = match proc.get_epoll_instance_mut(epfd) {
|
let epoll_instance = match proc.get_epoll_instance_mut(epfd) {
|
||||||
Ok(ins) => ins,
|
Ok(ins) => ins,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
return Err(err);
|
return Err(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let ret = epollInstance.control(op, fd, &_event)?;
|
let ret = epoll_instance.control(op, fd, &_event)?;
|
||||||
return Ok(ret);
|
return Ok(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,26 +318,26 @@ impl Syscall<'_> {
|
|||||||
events: *mut EpollEvent,
|
events: *mut EpollEvent,
|
||||||
maxevents: usize,
|
maxevents: usize,
|
||||||
timeout_msecs: usize,
|
timeout_msecs: usize,
|
||||||
sigset_t: usize,
|
_sigset_t: usize,
|
||||||
) -> SysResult {
|
) -> SysResult {
|
||||||
info!("epoll_pwait: epfd: {}, timeout: {:?}", epfd, timeout_msecs);
|
info!("epoll_pwait: epfd: {}, timeout: {:?}", epfd, timeout_msecs);
|
||||||
|
|
||||||
let mut proc = self.process();
|
let proc = self.process();
|
||||||
let events = unsafe { self.vm().check_write_array(events, maxevents)? };
|
let events = unsafe { self.vm().check_write_array(events, maxevents)? };
|
||||||
let epollInstance = proc.get_epoll_instance(epfd)?;
|
let epoll_instance = proc.get_epoll_instance(epfd)?;
|
||||||
|
|
||||||
// add new fds which are registered by epoll_ctl after latest epoll_pwait
|
// add new fds which are registered by epoll_ctl after latest epoll_pwait
|
||||||
epollInstance.readyList.lock().clear();
|
epoll_instance.ready_list.lock().clear();
|
||||||
epollInstance
|
epoll_instance
|
||||||
.readyList
|
.ready_list
|
||||||
.lock()
|
.lock()
|
||||||
.extend(epollInstance.newCtlList.lock().clone());
|
.extend(epoll_instance.new_ctl_list.lock().clone());
|
||||||
epollInstance.newCtlList.lock().clear();
|
epoll_instance.new_ctl_list.lock().clear();
|
||||||
|
|
||||||
// if registered fd has data to handle and its mode isn't epollet, we need
|
// if registered fd has data to handle and its mode isn't epollet, we need
|
||||||
// to add it to the list.
|
// to add it to the list.
|
||||||
let keys: Vec<_> = epollInstance.events.keys().cloned().collect();
|
let keys: Vec<_> = epoll_instance.events.keys().cloned().collect();
|
||||||
for (k, v) in epollInstance.events.iter() {
|
for (k, v) in epoll_instance.events.iter() {
|
||||||
if !v.contains(EpollEvent::EPOLLET) {
|
if !v.contains(EpollEvent::EPOLLET) {
|
||||||
match &proc.files.get(k) {
|
match &proc.files.get(k) {
|
||||||
None => {
|
None => {
|
||||||
@ -347,8 +346,8 @@ impl Syscall<'_> {
|
|||||||
Some(file_like) => {
|
Some(file_like) => {
|
||||||
let status = file_like.poll()?;
|
let status = file_like.poll()?;
|
||||||
if status.write || status.read || status.error {
|
if status.write || status.read || status.error {
|
||||||
let mut readylist = epollInstance.readyList.lock();
|
let mut ready_list = epoll_instance.ready_list.lock();
|
||||||
readylist.insert(*k);
|
ready_list.insert(*k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -358,11 +357,11 @@ impl Syscall<'_> {
|
|||||||
|
|
||||||
let mut callbacks = alloc::vec![];
|
let mut callbacks = alloc::vec![];
|
||||||
for fd in &keys {
|
for fd in &keys {
|
||||||
let mut proc = self.process();
|
let proc = self.process();
|
||||||
match proc.files.get(&fd) {
|
match proc.files.get(&fd) {
|
||||||
Some(file_like) => {
|
Some(file_like) => {
|
||||||
match file_like {
|
match file_like {
|
||||||
FileLike::File(file) => {
|
FileLike::File(_file) => {
|
||||||
&crate::fs::STDIN.pushed.register_epoll_list(
|
&crate::fs::STDIN.pushed.register_epoll_list(
|
||||||
self.thread.proc.clone(),
|
self.thread.proc.clone(),
|
||||||
thread::current().id(),
|
thread::current().id(),
|
||||||
@ -371,7 +370,7 @@ impl Syscall<'_> {
|
|||||||
);
|
);
|
||||||
callbacks.push((0, thread::current().id(), epfd, *fd));
|
callbacks.push((0, thread::current().id(), epfd, *fd));
|
||||||
}
|
}
|
||||||
FileLike::Socket(socket) => {
|
FileLike::Socket(_socket) => {
|
||||||
&(*crate::drivers::SOCKET_ACTIVITY).register_epoll_list(
|
&(*crate::drivers::SOCKET_ACTIVITY).register_epoll_list(
|
||||||
self.thread.proc.clone(),
|
self.thread.proc.clone(),
|
||||||
thread::current().id(),
|
thread::current().id(),
|
||||||
@ -380,7 +379,7 @@ impl Syscall<'_> {
|
|||||||
);
|
);
|
||||||
callbacks.push((1, thread::current().id(), epfd, *fd));
|
callbacks.push((1, thread::current().id(), epfd, *fd));
|
||||||
}
|
}
|
||||||
FileLike::EpollInstance(instance) => {
|
FileLike::EpollInstance(_) => {
|
||||||
return Err(SysError::EINVAL);
|
return Err(SysError::EINVAL);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -390,23 +389,22 @@ impl Syscall<'_> {
|
|||||||
drop(proc);
|
drop(proc);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut condvars = alloc::vec![&(*TICK_ACTIVITY), &STDIN.pushed, &(*SOCKET_ACTIVITY)];
|
let condvars = alloc::vec![&(*TICK_ACTIVITY), &STDIN.pushed, &(*SOCKET_ACTIVITY)];
|
||||||
|
|
||||||
let begin_time_ms = crate::trap::uptime_msec();
|
let begin_time_ms = crate::trap::uptime_msec();
|
||||||
let condition = move || {
|
let condition = move || {
|
||||||
use PollEvents as PE;
|
|
||||||
let mut proc = self.process();
|
let mut proc = self.process();
|
||||||
|
|
||||||
let epollInstance = match proc.get_epoll_instance_mut(epfd) {
|
let epoll_instance = match proc.get_epoll_instance_mut(epfd) {
|
||||||
Ok(ins) => ins,
|
Ok(ins) => ins,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
return Some(Err(err));
|
return Some(Err(err));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let readylist = epollInstance.readyList.lock().clone();
|
let ready_list = epoll_instance.ready_list.lock().clone();
|
||||||
let mut events_num = 0;
|
let mut events_num = 0;
|
||||||
|
|
||||||
for infd in readylist.iter() {
|
for infd in ready_list.iter() {
|
||||||
let mut status: PollStatus = Default::default();
|
let mut status: PollStatus = Default::default();
|
||||||
{
|
{
|
||||||
if let Some(file_like) = proc.files.get(&infd) {
|
if let Some(file_like) = proc.files.get(&infd) {
|
||||||
@ -421,13 +419,13 @@ impl Syscall<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
let epollInstance = match proc.get_epoll_instance_mut(epfd) {
|
let epoll_instance = match proc.get_epoll_instance_mut(epfd) {
|
||||||
Ok(ins) => ins,
|
Ok(ins) => ins,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
return Some(Err(err));
|
return Some(Err(err));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let epollevent = epollInstance.events.get_mut(&infd)?;
|
let epollevent = epoll_instance.events.get_mut(&infd)?;
|
||||||
|
|
||||||
if status.error {
|
if status.error {
|
||||||
events[events_num].events = EpollEvent::EPOLLERR;
|
events[events_num].events = EpollEvent::EPOLLERR;
|
||||||
@ -450,13 +448,13 @@ impl Syscall<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
let epollInstance = match proc.get_epoll_instance_mut(epfd) {
|
let epoll_instance = match proc.get_epoll_instance_mut(epfd) {
|
||||||
Ok(ins) => ins,
|
Ok(ins) => ins,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
return Some(Err(err));
|
return Some(Err(err));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
epollInstance.readyList.lock().clear();
|
epoll_instance.ready_list.lock().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
drop(proc);
|
drop(proc);
|
||||||
@ -607,7 +605,7 @@ impl Syscall<'_> {
|
|||||||
dirfd as isize, path, mode, flags
|
dirfd as isize, path, mode, flags
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let inode =
|
let _inode =
|
||||||
proc.lookup_inode_at(dirfd, &path, !flags.contains(AtFlags::SYMLINK_NOFOLLOW))?;
|
proc.lookup_inode_at(dirfd, &path, !flags.contains(AtFlags::SYMLINK_NOFOLLOW))?;
|
||||||
Ok(0)
|
Ok(0)
|
||||||
}
|
}
|
||||||
@ -1721,8 +1719,8 @@ const FD_PER_ITEM: usize = 8 * size_of::<u32>();
|
|||||||
const MAX_FDSET_SIZE: usize = 1024 / FD_PER_ITEM;
|
const MAX_FDSET_SIZE: usize = 1024 / FD_PER_ITEM;
|
||||||
|
|
||||||
struct FdSet {
|
struct FdSet {
|
||||||
bitset: &'static mut BitSlice<LittleEndian, u32>,
|
bitset: &'static mut BitSlice<Lsb0, u32>,
|
||||||
origin: BitVec<LittleEndian, u32>,
|
origin: BitVec<Lsb0, u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FdSet {
|
impl FdSet {
|
||||||
@ -1740,7 +1738,7 @@ impl FdSet {
|
|||||||
return Err(SysError::EINVAL);
|
return Err(SysError::EINVAL);
|
||||||
}
|
}
|
||||||
let slice = unsafe { vm.check_write_array(addr, len)? };
|
let slice = unsafe { vm.check_write_array(addr, len)? };
|
||||||
let bitset: &'static mut BitSlice<LittleEndian, u32> = slice.into();
|
let bitset: &'static mut BitSlice<Lsb0, u32> = slice.into();
|
||||||
debug!("bitset {:?}", bitset);
|
debug!("bitset {:?}", bitset);
|
||||||
|
|
||||||
// save the fdset, and clear it
|
// save the fdset, and clear it
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
use crate::sync::Semaphore;
|
#![allow(dead_code)]
|
||||||
use crate::sync::SpinLock as Mutex;
|
|
||||||
use alloc::{boxed::Box, collections::BTreeMap, string::String, sync::Arc, sync::Weak, vec::Vec};
|
|
||||||
use bitflags::*;
|
use bitflags::*;
|
||||||
use core::cell::UnsafeCell;
|
|
||||||
use spin::RwLock;
|
|
||||||
|
|
||||||
pub use crate::ipc::*;
|
pub use crate::ipc::*;
|
||||||
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
use crate::lkm::manager::ModuleManager;
|
use crate::lkm::manager::ModuleManager;
|
||||||
use crate::sync::Mutex;
|
|
||||||
use crate::syscall::{check_and_clone_cstr, SysResult, Syscall};
|
use crate::syscall::{check_and_clone_cstr, SysResult, Syscall};
|
||||||
use alloc::collections::btree_map::BTreeMap;
|
|
||||||
use compression::prelude::Action;
|
|
||||||
|
|
||||||
impl Syscall<'_> {
|
impl Syscall<'_> {
|
||||||
pub fn sys_init_module(
|
pub fn sys_init_module(
|
||||||
@ -11,7 +8,7 @@ impl Syscall<'_> {
|
|||||||
len: usize,
|
len: usize,
|
||||||
param_values: *const u8,
|
param_values: *const u8,
|
||||||
) -> SysResult {
|
) -> SysResult {
|
||||||
let mut proc = self.process();
|
let _proc = self.process();
|
||||||
let modimg = unsafe { self.vm().check_read_array(module_image, len)? };
|
let modimg = unsafe { self.vm().check_read_array(module_image, len)? };
|
||||||
let copied_param_values = check_and_clone_cstr(param_values)?;
|
let copied_param_values = check_and_clone_cstr(param_values)?;
|
||||||
|
|
||||||
@ -19,7 +16,7 @@ impl Syscall<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn sys_delete_module(&mut self, module_name: *const u8, flags: u32) -> SysResult {
|
pub fn sys_delete_module(&mut self, module_name: *const u8, flags: u32) -> SysResult {
|
||||||
let mut proc = self.process();
|
let _proc = self.process();
|
||||||
let copied_modname = check_and_clone_cstr(module_name)?;
|
let copied_modname = check_and_clone_cstr(module_name)?;
|
||||||
info!("[LKM] Removing module {:?}", copied_modname);
|
info!("[LKM] Removing module {:?}", copied_modname);
|
||||||
let ret = ModuleManager::with(|kmm| kmm.delete_module(&copied_modname, flags));
|
let ret = ModuleManager::with(|kmm| kmm.delete_module(&copied_modname, flags));
|
||||||
|
@ -71,7 +71,7 @@ impl Syscall<'_> {
|
|||||||
"mprotect: addr={:#x}, size={:#x}, prot={:?}",
|
"mprotect: addr={:#x}, size={:#x}, prot={:?}",
|
||||||
addr, len, prot
|
addr, len, prot
|
||||||
);
|
);
|
||||||
let attr = prot.to_attr();
|
let _attr = prot.to_attr();
|
||||||
|
|
||||||
// FIXME: properly set the attribute of the area
|
// FIXME: properly set the attribute of the area
|
||||||
// now some mut ptr check is fault
|
// now some mut ptr check is fault
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::arch::cpu;
|
use crate::arch::cpu;
|
||||||
use crate::consts::USER_STACK_SIZE;
|
use crate::consts::USER_STACK_SIZE;
|
||||||
|
@ -406,7 +406,7 @@ impl Syscall<'_> {
|
|||||||
SYS_PIPE => {
|
SYS_PIPE => {
|
||||||
let fd_ptr = args[0] as *mut u32;
|
let fd_ptr = args[0] as *mut u32;
|
||||||
match self.sys_pipe(fd_ptr) {
|
match self.sys_pipe(fd_ptr) {
|
||||||
Ok(code) => {
|
Ok(_code) => {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.tf.v0 = *fd_ptr as usize;
|
self.tf.v0 = *fd_ptr as usize;
|
||||||
self.tf.v1 = *(fd_ptr.add(1)) as usize;
|
self.tf.v1 = *(fd_ptr.add(1)) as usize;
|
||||||
|
@ -519,15 +519,15 @@ enum_with_unknown! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const IPPROTO_IP: usize = 0;
|
pub const IPPROTO_IP: usize = 0;
|
||||||
const IPPROTO_ICMP: usize = 1;
|
pub const IPPROTO_ICMP: usize = 1;
|
||||||
const IPPROTO_TCP: usize = 6;
|
pub const IPPROTO_TCP: usize = 6;
|
||||||
|
|
||||||
const SOL_SOCKET: usize = 1;
|
pub const SOL_SOCKET: usize = 1;
|
||||||
const SO_SNDBUF: usize = 7;
|
pub const SO_SNDBUF: usize = 7;
|
||||||
const SO_RCVBUF: usize = 8;
|
pub const SO_RCVBUF: usize = 8;
|
||||||
const SO_LINGER: usize = 13;
|
pub const SO_LINGER: usize = 13;
|
||||||
|
|
||||||
const TCP_CONGESTION: usize = 13;
|
pub const TCP_CONGESTION: usize = 13;
|
||||||
|
|
||||||
const IP_HDRINCL: usize = 3;
|
pub const IP_HDRINCL: usize = 3;
|
||||||
|
@ -13,6 +13,7 @@ impl Syscall<'_> {
|
|||||||
Ok(pid)
|
Ok(pid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
pub fn sys_vfork(&mut self) -> SysResult {
|
pub fn sys_vfork(&mut self) -> SysResult {
|
||||||
self.sys_fork()
|
self.sys_fork()
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ impl Syscall<'_> {
|
|||||||
Ok(0)
|
Ok(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
pub fn sys_time(&mut self, time: *mut u64) -> SysResult {
|
pub fn sys_time(&mut self, time: *mut u64) -> SysResult {
|
||||||
let sec = get_epoch_usec() / USEC_PER_SEC;
|
let sec = get_epoch_usec() / USEC_PER_SEC;
|
||||||
if time as usize != 0 {
|
if time as usize != 0 {
|
||||||
@ -64,7 +65,7 @@ impl Syscall<'_> {
|
|||||||
info!("times: buf: {:?}", buf);
|
info!("times: buf: {:?}", buf);
|
||||||
let buf = unsafe { self.vm().check_write_ptr(buf)? };
|
let buf = unsafe { self.vm().check_write_ptr(buf)? };
|
||||||
|
|
||||||
let tick_base = *TICK_BASE;
|
let _tick_base = *TICK_BASE;
|
||||||
let tick = unsafe { crate::trap::TICK as u64 };
|
let tick = unsafe { crate::trap::TICK as u64 };
|
||||||
|
|
||||||
let new_buf = Tms {
|
let new_buf = Tms {
|
||||||
|
Loading…
Reference in New Issue
Block a user