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