mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-25 17:33:28 +04:00
merge
This commit is contained in:
commit
47dade0c73
5
.github/workflows/main.yml
vendored
5
.github/workflows/main.yml
vendored
@ -7,11 +7,10 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: rm rust-toolchain
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: nightly
|
||||
toolchain: nightly-2020-04-06
|
||||
override: true
|
||||
components: rustfmt, clippy
|
||||
- name: Check code format
|
||||
@ -30,7 +29,7 @@ jobs:
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: nightly-2020-01-17
|
||||
toolchain: nightly-2020-04-06
|
||||
components: rust-src, llvm-tools-preview
|
||||
|
||||
- name: Cache QEMU
|
||||
|
62
kernel/Cargo.lock
generated
62
kernel/Cargo.lock
generated
@ -107,9 +107,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "buddy_system_allocator"
|
||||
version = "0.3.5"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rustversion 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@ -330,7 +331,7 @@ name = "rboot"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uefi 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uefi 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"x86_64 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"xmas-elf 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
@ -348,7 +349,7 @@ dependencies = [
|
||||
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitmap-allocator 0.1.0 (git+https://github.com/rcore-os/bitmap-allocator)",
|
||||
"bitvec 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"buddy_system_allocator 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"buddy_system_allocator 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"compression 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"device_tree 1.0.3 (git+https://github.com/rcore-os/device_tree-rs)",
|
||||
@ -362,11 +363,11 @@ dependencies = [
|
||||
"raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rboot 0.1.2",
|
||||
"rcore-console 0.1.0 (git+https://github.com/rcore-os/rcore-console?rev=b7bacf9)",
|
||||
"rcore-fs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=e17b27b)",
|
||||
"rcore-fs-devfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=e17b27b)",
|
||||
"rcore-fs-mountfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=e17b27b)",
|
||||
"rcore-fs-ramfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=e17b27b)",
|
||||
"rcore-fs-sfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=e17b27b)",
|
||||
"rcore-fs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7f5eeac)",
|
||||
"rcore-fs-devfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7f5eeac)",
|
||||
"rcore-fs-mountfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7f5eeac)",
|
||||
"rcore-fs-ramfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7f5eeac)",
|
||||
"rcore-fs-sfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7f5eeac)",
|
||||
"rcore-memory 0.1.0",
|
||||
"rcore-thread 0.1.0 (git+https://github.com/rcore-os/rcore-thread?rev=d727949b)",
|
||||
"riscv 0.5.0 (git+https://github.com/rcore-os/riscv)",
|
||||
@ -392,7 +393,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "rcore-fs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rcore-os/rcore-fs?rev=e17b27b#e17b27b3d257f23ed8ba43d902c909d23245a008"
|
||||
source = "git+https://github.com/rcore-os/rcore-fs?rev=7f5eeac#7f5eeac8b77f6bab11f6f2ce631a194bee658555"
|
||||
dependencies = [
|
||||
"filetime 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -402,42 +403,42 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "rcore-fs-devfs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rcore-os/rcore-fs?rev=e17b27b#e17b27b3d257f23ed8ba43d902c909d23245a008"
|
||||
source = "git+https://github.com/rcore-os/rcore-fs?rev=7f5eeac#7f5eeac8b77f6bab11f6f2ce631a194bee658555"
|
||||
dependencies = [
|
||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rcore-fs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=e17b27b)",
|
||||
"rcore-fs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7f5eeac)",
|
||||
"spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rcore-fs-mountfs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rcore-os/rcore-fs?rev=e17b27b#e17b27b3d257f23ed8ba43d902c909d23245a008"
|
||||
source = "git+https://github.com/rcore-os/rcore-fs?rev=7f5eeac#7f5eeac8b77f6bab11f6f2ce631a194bee658555"
|
||||
dependencies = [
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rcore-fs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=e17b27b)",
|
||||
"rcore-fs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7f5eeac)",
|
||||
"spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rcore-fs-ramfs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rcore-os/rcore-fs?rev=e17b27b#e17b27b3d257f23ed8ba43d902c909d23245a008"
|
||||
source = "git+https://github.com/rcore-os/rcore-fs?rev=7f5eeac#7f5eeac8b77f6bab11f6f2ce631a194bee658555"
|
||||
dependencies = [
|
||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rcore-fs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=e17b27b)",
|
||||
"rcore-fs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7f5eeac)",
|
||||
"spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rcore-fs-sfs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rcore-os/rcore-fs?rev=e17b27b#e17b27b3d257f23ed8ba43d902c909d23245a008"
|
||||
source = "git+https://github.com/rcore-os/rcore-fs?rev=7f5eeac#7f5eeac8b77f6bab11f6f2ce631a194bee658555"
|
||||
dependencies = [
|
||||
"bitvec 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rcore-fs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=e17b27b)",
|
||||
"rcore-fs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7f5eeac)",
|
||||
"spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"static_assertions 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
@ -496,6 +497,16 @@ dependencies = [
|
||||
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "0.9.0"
|
||||
@ -569,7 +580,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "uefi"
|
||||
version = "0.4.3"
|
||||
version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -717,7 +728,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
||||
"checksum bitmap-allocator 0.1.0 (git+https://github.com/rcore-os/bitmap-allocator)" = "<none>"
|
||||
"checksum bitvec 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1fe4300c1d7a9ea6f3e3f39c10b39862bb79e1175c0572b6b49539a30e5562f5"
|
||||
"checksum buddy_system_allocator 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "59da15ef556589ee78370281d75b67f2d69ed26465ec0e0f3961e2021502426f"
|
||||
"checksum buddy_system_allocator 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9e953b958d83e13a44b1ead5b6aaa2a5f854bd5170239a66b606e030a14d018f"
|
||||
"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"
|
||||
"checksum cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0"
|
||||
"checksum cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)" = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd"
|
||||
@ -747,17 +758,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d"
|
||||
"checksum raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf"
|
||||
"checksum rcore-console 0.1.0 (git+https://github.com/rcore-os/rcore-console?rev=b7bacf9)" = "<none>"
|
||||
"checksum rcore-fs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=e17b27b)" = "<none>"
|
||||
"checksum rcore-fs-devfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=e17b27b)" = "<none>"
|
||||
"checksum rcore-fs-mountfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=e17b27b)" = "<none>"
|
||||
"checksum rcore-fs-ramfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=e17b27b)" = "<none>"
|
||||
"checksum rcore-fs-sfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=e17b27b)" = "<none>"
|
||||
"checksum rcore-fs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7f5eeac)" = "<none>"
|
||||
"checksum rcore-fs-devfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7f5eeac)" = "<none>"
|
||||
"checksum rcore-fs-mountfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7f5eeac)" = "<none>"
|
||||
"checksum rcore-fs-ramfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7f5eeac)" = "<none>"
|
||||
"checksum rcore-fs-sfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7f5eeac)" = "<none>"
|
||||
"checksum rcore-thread 0.1.0 (git+https://github.com/rcore-os/rcore-thread?rev=d727949b)" = "<none>"
|
||||
"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
|
||||
"checksum register 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e10f31b6d2299e5620986ad9fcdd66463e125ad72af4f403f9aedf7592d5ccdb"
|
||||
"checksum riscv 0.5.0 (git+https://github.com/rcore-os/riscv)" = "<none>"
|
||||
"checksum rlibc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc874b127765f014d792f16763a81245ab80500e2ad921ed4ee9e82481ee08fe"
|
||||
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
||||
"checksum rustversion 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b3bba175698996010c4f6dce5e7f173b6eb781fce25d2cfc45e27091ce0b79f6"
|
||||
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
||||
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||
"checksum smoltcp 0.5.0 (git+https://github.com/rcore-os/smoltcp?rev=5bd87c7c)" = "<none>"
|
||||
@ -768,7 +780,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9"
|
||||
"checksum uart_16550 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "58fc0bc8ff1beb1436e8c4ce9c4b47f6f6c1376b56fb91505fabeef13743eb33"
|
||||
"checksum ucs2 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "85061f4e43545a613c0da6b87725bf23f8da8613cf2473719c4f71a270c4ce8a"
|
||||
"checksum uefi 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "36c63ddfef80d9e7f1318917f6c05135b3b98027e973a9e9f0a6aebe87b95934"
|
||||
"checksum uefi 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5cec6a2850639f588cc8042140b5deaa2f2170c23db5adb08f4316fa04cdb4a0"
|
||||
"checksum uefi-macros 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c7d4a1b0215dc72e83d8d501b3275eb59477d3b595be8861abfb8ab110180955"
|
||||
"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
||||
"checksum usize_conversions 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f70329e2cbe45d6c97a5112daad40c34cd9a4e18edb5a2a18fefeb584d8d25e5"
|
||||
|
@ -55,7 +55,7 @@ bitflags = "1.2"
|
||||
bit_field = "0.10"
|
||||
volatile = "0.2"
|
||||
bitvec = { version = "0.17", default-features = false, features = ["alloc"] }
|
||||
buddy_system_allocator = "0.3"
|
||||
buddy_system_allocator = "0.3.9"
|
||||
pci = { git = "https://github.com/rcore-os/pci-rs" }
|
||||
device_tree = { git = "https://github.com/rcore-os/device_tree-rs" }
|
||||
isomorphic_drivers = { git = "https://github.com/rcore-os/isomorphic_drivers", features = ["log"] }
|
||||
@ -66,11 +66,11 @@ bitmap-allocator = { git = "https://github.com/rcore-os/bitmap-allocator" }
|
||||
rcore-console = { git = "https://github.com/rcore-os/rcore-console", rev = "b7bacf9", default-features = false }
|
||||
rcore-memory = { path = "../crate/memory" }
|
||||
rcore-thread = { git = "https://github.com/rcore-os/rcore-thread", rev = "d727949b" }
|
||||
rcore-fs = { git = "https://github.com/rcore-os/rcore-fs", rev = "e17b27b" }
|
||||
rcore-fs-sfs = { git = "https://github.com/rcore-os/rcore-fs", rev = "e17b27b" }
|
||||
rcore-fs-ramfs = { git = "https://github.com/rcore-os/rcore-fs", rev = "e17b27b" }
|
||||
rcore-fs-mountfs = { git = "https://github.com/rcore-os/rcore-fs", rev = "e17b27b" }
|
||||
rcore-fs-devfs = { git = "https://github.com/rcore-os/rcore-fs", rev = "e17b27b" }
|
||||
rcore-fs = { git = "https://github.com/rcore-os/rcore-fs", rev = "7f5eeac" }
|
||||
rcore-fs-sfs = { git = "https://github.com/rcore-os/rcore-fs", rev = "7f5eeac" }
|
||||
rcore-fs-ramfs = { git = "https://github.com/rcore-os/rcore-fs", rev = "7f5eeac" }
|
||||
rcore-fs-mountfs = { git = "https://github.com/rcore-os/rcore-fs", rev = "7f5eeac" }
|
||||
rcore-fs-devfs = { git = "https://github.com/rcore-os/rcore-fs", rev = "7f5eeac" }
|
||||
compression = { version = "0.1.4", default-features = false, features = ["gzip"] }
|
||||
|
||||
|
||||
|
@ -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") {
|
||||
|
@ -12,7 +12,7 @@ pub static CONSOLE: Mutex<Option<RCoreConsole>> = Mutex::new(None);
|
||||
/// Initialize console driver
|
||||
pub fn init() {
|
||||
if cfg!(feature = "consolegraphic") {
|
||||
if let Some(fb) = FRAME_BUFFER.lock().take() {
|
||||
if let Some(fb) = FRAME_BUFFER.write().take() {
|
||||
// FIXME: now take FrameBuffer out of global variable, then move into Console
|
||||
let console = Console::on_frame_buffer(fb.fb_info.xres, fb.fb_info.yres, fb);
|
||||
*CONSOLE.lock() = Some(console);
|
||||
|
@ -2,9 +2,8 @@
|
||||
|
||||
use alloc::string::String;
|
||||
use core::fmt;
|
||||
use lazy_static::lazy_static;
|
||||
use log::*;
|
||||
use spin::Mutex;
|
||||
use spin::RwLock;
|
||||
|
||||
/// Framebuffer information
|
||||
#[repr(C)]
|
||||
@ -195,23 +194,48 @@ impl Framebuffer {
|
||||
}
|
||||
}
|
||||
|
||||
/// Copy buffer `[src_off .. src_off + size]` to `[dst_off .. dst_off + size]`.
|
||||
/// `dst_off`, `src_off` and `size` must be aligned with `usize`.
|
||||
pub fn copy(&mut self, dst_off: usize, src_off: usize, size: usize) {
|
||||
const USIZE: usize = core::mem::size_of::<usize>();
|
||||
let mut dst = self.base_addr() + dst_off;
|
||||
let mut src = self.base_addr() + src_off;
|
||||
let src_end = src + size;
|
||||
while src < src_end {
|
||||
unsafe { *(dst as *mut usize) = *(src as *mut usize) }
|
||||
dst += USIZE;
|
||||
src += USIZE;
|
||||
/// Read buffer data starts at `offset` to `buf`.
|
||||
pub fn read_at(&self, offset: usize, buf: &mut [u8]) -> usize {
|
||||
if offset >= self.fb_info.screen_size {
|
||||
return 0;
|
||||
}
|
||||
let count = buf.len().min(self.fb_info.screen_size - offset);
|
||||
let data = unsafe {
|
||||
core::slice::from_raw_parts((self.buf.base_addr + offset) as *const u8, count)
|
||||
};
|
||||
buf[..count].copy_from_slice(&data);
|
||||
count
|
||||
}
|
||||
|
||||
/// Fill buffer `[offset .. offset + size]` with `pixel`.
|
||||
/// `offset` and `size` must be aligned with `usize`.
|
||||
pub fn fill(&mut self, offset: usize, size: usize, pixel: u32) {
|
||||
/// Write buffer data starts at `offset` to `buf`.
|
||||
pub fn write_at(&mut self, offset: usize, buf: &[u8]) -> usize {
|
||||
if offset > self.fb_info.screen_size {
|
||||
return 0;
|
||||
}
|
||||
let count = buf.len().min(self.fb_info.screen_size - offset);
|
||||
let data = unsafe {
|
||||
core::slice::from_raw_parts_mut((self.buf.base_addr + offset) as *mut u8, count)
|
||||
};
|
||||
data.copy_from_slice(&buf[..count]);
|
||||
count
|
||||
}
|
||||
|
||||
/// Copy buffer `[src_off .. src_off + count]` to `[dst_off .. dst_off + count]`.
|
||||
pub fn copy(&mut self, dst_off: usize, src_off: usize, count: usize) {
|
||||
let size = self.fb_info.screen_size;
|
||||
if src_off >= size || dst_off >= size {
|
||||
return;
|
||||
}
|
||||
let count = count.min(size - src_off).min(size - dst_off);
|
||||
unsafe {
|
||||
let buf = core::slice::from_raw_parts_mut(self.buf.base_addr as *mut u8, size);
|
||||
buf.copy_within(src_off..src_off + count, dst_off)
|
||||
};
|
||||
}
|
||||
|
||||
/// Fill buffer `[offset .. offset + count]` with `pixel`.
|
||||
/// `offset` and `count` must be aligned with `usize`.
|
||||
pub fn fill(&mut self, offset: usize, count: usize, pixel: u32) {
|
||||
const USIZE: usize = core::mem::size_of::<usize>();
|
||||
let mut value: usize = 0;
|
||||
let depth = self.fb_info.depth as usize;
|
||||
@ -222,8 +246,13 @@ impl Framebuffer {
|
||||
value += pixel as usize & mask;
|
||||
}
|
||||
|
||||
let offset = offset & !(USIZE - 1);
|
||||
if offset >= self.fb_info.screen_size {
|
||||
return;
|
||||
}
|
||||
let count = (count & !(USIZE - 1)).min(self.fb_info.screen_size - offset);
|
||||
let mut start = self.base_addr() + offset;
|
||||
let end = start + size;
|
||||
let end = start + count;
|
||||
while start < end {
|
||||
unsafe { *(start as *mut usize) = value }
|
||||
start += USIZE;
|
||||
@ -280,7 +309,7 @@ impl ColorEncode for Rgb888 {
|
||||
}
|
||||
}
|
||||
|
||||
pub static FRAME_BUFFER: Mutex<Option<Framebuffer>> = Mutex::new(None);
|
||||
pub static FRAME_BUFFER: RwLock<Option<Framebuffer>> = RwLock::new(None);
|
||||
|
||||
/// Initialize framebuffer
|
||||
///
|
||||
@ -288,5 +317,5 @@ pub static FRAME_BUFFER: Mutex<Option<Framebuffer>> = Mutex::new(None);
|
||||
pub fn init(info: FramebufferInfo) {
|
||||
let fb = Framebuffer::new(info);
|
||||
info!("framebuffer: init end\n{:#x?}", fb);
|
||||
*FRAME_BUFFER.lock() = Some(fb);
|
||||
*FRAME_BUFFER.write() = Some(fb);
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -1,32 +1,43 @@
|
||||
use rcore_fs::vfs::*;
|
||||
//! Implement INode for framebuffer
|
||||
|
||||
use crate::drivers::gpu::fb::{ColorFormat, FramebufferInfo, FRAME_BUFFER};
|
||||
use crate::memory::phys_to_virt;
|
||||
use alloc::{string::String, sync::Arc, vec::Vec};
|
||||
use crate::syscall::MmapProt;
|
||||
use core::any::Any;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Vga;
|
||||
use rcore_fs::vfs::*;
|
||||
use rcore_memory::memory_set::handler::Linear;
|
||||
|
||||
impl INode for Vga {
|
||||
#[derive(Default)]
|
||||
pub struct Fbdev;
|
||||
|
||||
impl INode for Fbdev {
|
||||
fn read_at(&self, offset: usize, buf: &mut [u8]) -> Result<usize> {
|
||||
Err(FsError::NotSupported)
|
||||
}
|
||||
fn write_at(&self, _offset: usize, _buf: &[u8]) -> Result<usize> {
|
||||
info!("the _offset is {} {}", _offset, _buf[0]);
|
||||
let lock = FRAME_BUFFER.lock();
|
||||
if let Some(ref frame_buffer) = *lock {
|
||||
use core::slice;
|
||||
let frame_buffer_data = unsafe {
|
||||
slice::from_raw_parts_mut(
|
||||
frame_buffer.base_addr() as *mut u8,
|
||||
frame_buffer.framebuffer_size(),
|
||||
)
|
||||
};
|
||||
frame_buffer_data.copy_from_slice(&_buf);
|
||||
Ok(frame_buffer.framebuffer_size())
|
||||
info!(
|
||||
"fbdev read_at: offset={:#x} buf_len={:#x}",
|
||||
offset,
|
||||
buf.len()
|
||||
);
|
||||
if let Some(fb) = FRAME_BUFFER.read().as_ref() {
|
||||
Ok(fb.read_at(offset, buf))
|
||||
} else {
|
||||
Err(FsError::EntryNotFound)
|
||||
Err(FsError::NoDevice)
|
||||
}
|
||||
}
|
||||
fn write_at(&self, offset: usize, buf: &[u8]) -> Result<usize> {
|
||||
info!(
|
||||
"fbdev write_at: offset={:#x} buf_len={:#x}",
|
||||
offset,
|
||||
buf.len()
|
||||
);
|
||||
if let Some(fb) = FRAME_BUFFER.write().as_mut() {
|
||||
let count = fb.write_at(offset, buf);
|
||||
if count == buf.len() {
|
||||
Ok(count)
|
||||
} else {
|
||||
Err(FsError::NoDeviceSpace)
|
||||
}
|
||||
} else {
|
||||
Err(FsError::NoDevice)
|
||||
}
|
||||
}
|
||||
fn poll(&self) -> Result<PollStatus> {
|
||||
@ -41,18 +52,18 @@ impl INode for Vga {
|
||||
Ok(Metadata {
|
||||
dev: 0,
|
||||
inode: 0,
|
||||
size: 0x24000,
|
||||
size: 0,
|
||||
blk_size: 0,
|
||||
blocks: 0,
|
||||
atime: Timespec { sec: 0, nsec: 0 },
|
||||
mtime: Timespec { sec: 0, nsec: 0 },
|
||||
ctime: Timespec { sec: 0, nsec: 0 },
|
||||
type_: FileType::SymLink,
|
||||
mode: 0,
|
||||
nlinks: 0,
|
||||
type_: FileType::CharDevice,
|
||||
mode: 0o660,
|
||||
nlinks: 1,
|
||||
uid: 0,
|
||||
gid: 0,
|
||||
rdev: 0,
|
||||
rdev: make_rdev(29, 0),
|
||||
})
|
||||
}
|
||||
fn io_control(&self, cmd: u32, data: usize) -> Result<()> {
|
||||
@ -62,14 +73,14 @@ impl INode for Vga {
|
||||
match cmd {
|
||||
FBIOGET_FSCREENINFO => {
|
||||
let fb_fix_info = unsafe { &mut *(data as *mut FbFixScreeninfo) };
|
||||
if let Some(fb) = FRAME_BUFFER.lock().as_ref() {
|
||||
if let Some(fb) = FRAME_BUFFER.read().as_ref() {
|
||||
fb_fix_info.fill_from(&fb.fb_info);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
FBIOGET_VSCREENINFO => {
|
||||
let fb_var_info = unsafe { &mut *(data as *mut FbVarScreeninfo) };
|
||||
if let Some(fb) = FRAME_BUFFER.lock().as_ref() {
|
||||
if let Some(fb) = FRAME_BUFFER.read().as_ref() {
|
||||
fb_var_info.fill_from(&fb.fb_info);
|
||||
}
|
||||
Ok(())
|
||||
@ -80,12 +91,35 @@ impl INode for Vga {
|
||||
}
|
||||
}
|
||||
}
|
||||
fn mmap(&self, area: MMapArea) -> Result<()> {
|
||||
let attr = MmapProt::from_bits_truncate(area.prot).to_attr();
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
let attr = attr.mmio(crate::arch::paging::MMIOType::NormalNonCacheable as u8);
|
||||
|
||||
if let Some(fb) = FRAME_BUFFER.read().as_ref() {
|
||||
if area.offset + area.end_vaddr - area.start_vaddr > fb.framebuffer_size() {
|
||||
return Err(FsError::NoDeviceSpace);
|
||||
}
|
||||
let thread = unsafe { crate::process::current_thread() };
|
||||
thread.vm.lock().push(
|
||||
area.start_vaddr,
|
||||
area.end_vaddr,
|
||||
attr,
|
||||
Linear::new((fb.paddr() + area.offset - area.start_vaddr) as isize),
|
||||
"mmap_file",
|
||||
);
|
||||
Ok(())
|
||||
} else {
|
||||
Err(FsError::NoDevice)
|
||||
}
|
||||
}
|
||||
fn as_any_ref(&self) -> &dyn Any {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(u32)]
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
enum FbType {
|
||||
/// Packed Pixels
|
||||
@ -103,6 +137,7 @@ enum FbType {
|
||||
}
|
||||
|
||||
#[repr(u32)]
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
enum FbVisual {
|
||||
/// Monochr. 1=Black 0=White
|
9
kernel/src/fs/devfs/mod.rs
Normal file
9
kernel/src/fs/devfs/mod.rs
Normal file
@ -0,0 +1,9 @@
|
||||
//! Device file system mounted at /dev
|
||||
|
||||
mod fbdev;
|
||||
mod random;
|
||||
mod stdio;
|
||||
|
||||
pub use fbdev::*;
|
||||
pub use random::*;
|
||||
pub use stdio::*;
|
@ -1,14 +1,13 @@
|
||||
//! 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;
|
||||
|
||||
pub struct RandomINodeData {
|
||||
struct RandomINodeData {
|
||||
seed: u32,
|
||||
}
|
||||
|
@ -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 super::ioctl::*;
|
||||
use crate::process::Process;
|
||||
use crate::fs::ioctl::*;
|
||||
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 */
|
||||
|
@ -1,10 +1,14 @@
|
||||
//! File handle for process
|
||||
|
||||
use crate::memory::GlobalFrameAlloc;
|
||||
use crate::process::{current_thread, INodeForMap};
|
||||
use crate::syscall::MmapProt;
|
||||
use crate::thread;
|
||||
use alloc::{string::String, sync::Arc};
|
||||
use core::fmt;
|
||||
|
||||
use rcore_fs::vfs::{FsError, INode, Metadata, PollStatus, Result};
|
||||
use rcore_fs::vfs::{FileType, FsError, INode, MMapArea, Metadata, PollStatus, Result};
|
||||
use rcore_memory::memory_set::handler::File;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct FileHandle {
|
||||
@ -50,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();
|
||||
@ -68,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> {
|
||||
@ -141,6 +143,32 @@ impl FileHandle {
|
||||
self.inode.io_control(cmd, arg)
|
||||
}
|
||||
|
||||
pub fn mmap(&mut self, area: MMapArea) -> Result<()> {
|
||||
info!("mmap file path is {}", self.path);
|
||||
match self.inode.metadata()?.type_ {
|
||||
FileType::File => {
|
||||
let prot = MmapProt::from_bits_truncate(area.prot);
|
||||
let thread = unsafe { current_thread() };
|
||||
thread.vm.lock().push(
|
||||
area.start_vaddr,
|
||||
area.end_vaddr,
|
||||
prot.to_attr(),
|
||||
File {
|
||||
file: INodeForMap(self.inode.clone()),
|
||||
mem_start: area.start_vaddr,
|
||||
file_start: area.offset,
|
||||
file_end: area.offset + area.end_vaddr - area.start_vaddr,
|
||||
allocator: GlobalFrameAlloc,
|
||||
},
|
||||
"mmap_file",
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
FileType::CharDevice => self.inode.mmap(area),
|
||||
_ => Err(FsError::NotSupported),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn inode(&self) -> Arc<dyn INode> {
|
||||
self.inode.clone()
|
||||
}
|
||||
|
@ -4,11 +4,9 @@ use super::ioctl::*;
|
||||
use super::FileHandle;
|
||||
use crate::fs::epoll::EpollInstance;
|
||||
use crate::net::Socket;
|
||||
use crate::sync::Condvar;
|
||||
use crate::syscall::{SysError, SysResult};
|
||||
use alloc::boxed::Box;
|
||||
use alloc::vec::Vec;
|
||||
use rcore_fs::vfs::PollStatus;
|
||||
use rcore_fs::vfs::{MMapArea, PollStatus};
|
||||
|
||||
// TODO: merge FileLike to FileHandle ?
|
||||
// TODO: fix dup and remove Clone
|
||||
@ -24,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);
|
||||
}
|
||||
};
|
||||
@ -34,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);
|
||||
}
|
||||
};
|
||||
@ -51,7 +49,7 @@ impl FileLike {
|
||||
FileLike::Socket(socket) => {
|
||||
socket.ioctl(request, arg1, arg2, arg3)?;
|
||||
}
|
||||
FileLike::EpollInstance(instance) => {
|
||||
FileLike::EpollInstance(_) => {
|
||||
return Err(SysError::ENOSYS);
|
||||
}
|
||||
}
|
||||
@ -59,6 +57,13 @@ impl FileLike {
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn mmap(&mut self, area: MMapArea) -> SysResult {
|
||||
match self {
|
||||
FileLike::File(file) => file.mmap(area)?,
|
||||
_ => return Err(SysError::ENOSYS),
|
||||
};
|
||||
Ok(0)
|
||||
}
|
||||
pub fn poll(&self) -> Result<PollStatus, SysError> {
|
||||
let status = match self {
|
||||
FileLike::File(file) => file.poll()?,
|
||||
@ -66,20 +71,19 @@ impl FileLike {
|
||||
let (read, write, error) = socket.poll();
|
||||
PollStatus { read, write, error }
|
||||
}
|
||||
FileLike::EpollInstance(instance) => {
|
||||
FileLike::EpollInstance(_) => {
|
||||
return Err(SysError::ENOSYS);
|
||||
}
|
||||
};
|
||||
Ok(status)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
@ -90,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,14 +1,17 @@
|
||||
use alloc::{sync::Arc, vec::Vec};
|
||||
|
||||
use rcore_fs::dev::block_cache::BlockCache;
|
||||
use rcore_fs::vfs::*;
|
||||
use rcore_fs_devfs::{special::*, DevFS};
|
||||
use rcore_fs_devfs::{
|
||||
special::{NullINode, ZeroINode},
|
||||
DevFS,
|
||||
};
|
||||
use rcore_fs_mountfs::MountFS;
|
||||
use rcore_fs_ramfs::RamFS;
|
||||
use rcore_fs_sfs::SimpleFileSystem;
|
||||
|
||||
use crate::drivers::BlockDriver;
|
||||
use self::devfs::{Fbdev, RandomINode};
|
||||
|
||||
pub use self::devfs::{STDIN, STDOUT};
|
||||
pub use self::file::*;
|
||||
pub use self::file_like::*;
|
||||
pub use self::pipe::Pipe;
|
||||
@ -18,6 +21,7 @@ pub use self::stdio::{STDIN, STDOUT};
|
||||
pub use self::vga::*;
|
||||
pub use self::tty::TtyINode;
|
||||
|
||||
mod devfs;
|
||||
mod device;
|
||||
pub mod epoll;
|
||||
mod file;
|
||||
@ -52,6 +56,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()
|
||||
@ -89,6 +95,7 @@ lazy_static! {
|
||||
devfs.add("random", Arc::new(RandomINode::new(false))).expect("failed to mknod /dev/random");
|
||||
devfs.add("urandom", Arc::new(RandomINode::new(true))).expect("failed to mknod /dev/urandom");
|
||||
devfs.add("tty", Arc::new(TtyINode::default())).expect("failed to mknod /dev/tty");
|
||||
devfs.add("fb0", Arc::new(Fbdev::default())).expect("failed to mknod /dev/fb0");
|
||||
|
||||
// mount DevFS at /dev
|
||||
let dev = root.find(true, "dev").unwrap_or_else(|_| {
|
||||
|
@ -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::*;
|
||||
@ -50,7 +50,7 @@ impl INode for Pseudo {
|
||||
ctime: Timespec { sec: 0, nsec: 0 },
|
||||
type_: self.type_,
|
||||
mode: 0,
|
||||
nlinks: 0,
|
||||
nlinks: 1,
|
||||
uid: 0,
|
||||
gid: 0,
|
||||
rdev: 0,
|
||||
|
@ -26,7 +26,6 @@ impl INode for TtyINode {
|
||||
error: false,
|
||||
})
|
||||
}
|
||||
fn as_any_ref(&self) -> &dyn Any { self }
|
||||
|
||||
/// Get metadata of the INode
|
||||
fn metadata(&self) -> Result<Metadata> {
|
||||
@ -47,4 +46,6 @@ impl INode for TtyINode {
|
||||
rdev: make_rdev(5, 0),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn as_any_ref(&self) -> &dyn Any { self }
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,6 @@
|
||||
//! 完全照搬`std::sync::Semaphore`,std中已经废弃。
|
||||
//! 貌似在Rust中并不常用,一般都用`Mutex`。
|
||||
//!
|
||||
//! * `mpsc`: 消息传递通道。
|
||||
//! 多生产者-单消费者的FIFO队列。用于在线程间传递数据。
|
||||
//!
|
||||
//! * `test`: 测试。
|
||||
//! 目前分别用`Mutex`和`Condvar`(Monitor)实现了哲学家就餐问题。
|
||||
//!
|
||||
@ -55,7 +52,6 @@ pub use self::mutex::*;
|
||||
pub use self::semaphore::*;
|
||||
|
||||
mod condvar;
|
||||
pub mod mpsc;
|
||||
mod mutex;
|
||||
mod semaphore;
|
||||
pub mod test;
|
||||
|
@ -1,145 +0,0 @@
|
||||
use super::Condvar;
|
||||
use super::SpinLock as Mutex;
|
||||
use alloc::{collections::VecDeque, sync::Arc, sync::Weak};
|
||||
|
||||
struct Channel<T> {
|
||||
deque: Mutex<VecDeque<T>>,
|
||||
pushed: Condvar,
|
||||
}
|
||||
|
||||
impl<T> Default for Channel<T> {
|
||||
fn default() -> Self {
|
||||
Channel {
|
||||
deque: Mutex::<_>::default(),
|
||||
pushed: Condvar::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The receiving half of Rust's channel (or sync_channel) type.
|
||||
/// This half can only be owned by one thread.
|
||||
///
|
||||
/// Messages sent to the channel can be retrieved using recv.
|
||||
pub struct Receiver<T> {
|
||||
inner: Arc<Channel<T>>,
|
||||
}
|
||||
|
||||
unsafe impl<T: Send> Send for Receiver<T> {}
|
||||
|
||||
impl<T> !Sync for Receiver<T> {}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct RecvError;
|
||||
|
||||
impl<T> Receiver<T> {
|
||||
/// Attempts to wait for a value on this receiver,
|
||||
/// returning an error if the corresponding channel has hung up.
|
||||
pub fn recv(&self) -> Result<T, RecvError> {
|
||||
let mut deque = self.inner.deque.lock();
|
||||
while deque.is_empty() {
|
||||
deque = self.inner.pushed.wait(deque);
|
||||
}
|
||||
Ok(deque.pop_front().unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
/// The sending-half of Rust's asynchronous channel type.
|
||||
/// This half can only be owned by one thread, but it can be cloned to send to other threads.
|
||||
///
|
||||
/// Messages can be sent through this channel with send.
|
||||
#[derive(Clone)]
|
||||
pub struct Sender<T> {
|
||||
inner: Weak<Channel<T>>,
|
||||
}
|
||||
|
||||
unsafe impl<T: Send> Send for Sender<T> {}
|
||||
|
||||
impl<T> !Sync for Sender<T> {}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct SendError<T>(pub T);
|
||||
|
||||
impl<T> Sender<T> {
|
||||
/// Attempts to send a value on this channel,
|
||||
/// returning it back if it could not be sent.
|
||||
pub fn send(&self, t: T) -> Result<(), SendError<T>> {
|
||||
match self.inner.upgrade() {
|
||||
None => Err(SendError(t)),
|
||||
Some(inner) => {
|
||||
let mut deque = inner.deque.lock();
|
||||
deque.push_back(t);
|
||||
inner.pushed.notify_one();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a new asynchronous channel, returning the sender/receiver halves.
|
||||
pub fn channel<T>() -> (Sender<T>, Receiver<T>) {
|
||||
let channel = Arc::new(Channel::<T>::default());
|
||||
let sender = Sender {
|
||||
inner: Arc::downgrade(&channel),
|
||||
};
|
||||
let receiver = Receiver { inner: channel };
|
||||
(sender, receiver)
|
||||
}
|
||||
|
||||
pub mod test {
|
||||
//! Copied from std::mpsc::test
|
||||
|
||||
use super::*;
|
||||
use crate::thread;
|
||||
use alloc::boxed::Box;
|
||||
|
||||
fn smoke() {
|
||||
let (tx, rx) = channel::<i32>();
|
||||
tx.send(1).unwrap();
|
||||
assert_eq!(rx.recv().unwrap(), 1);
|
||||
}
|
||||
|
||||
fn drop_full() {
|
||||
let (tx, _rx) = channel::<Box<isize>>();
|
||||
tx.send(Box::new(1)).unwrap();
|
||||
}
|
||||
|
||||
fn drop_full_shared() {
|
||||
let (tx, _rx) = channel::<Box<isize>>();
|
||||
drop(tx.clone());
|
||||
drop(tx.clone());
|
||||
tx.send(Box::new(1)).unwrap();
|
||||
}
|
||||
|
||||
fn smoke_shared() {
|
||||
let (tx, rx) = channel::<i32>();
|
||||
tx.send(1).unwrap();
|
||||
assert_eq!(rx.recv().unwrap(), 1);
|
||||
let tx = tx.clone();
|
||||
tx.send(1).unwrap();
|
||||
assert_eq!(rx.recv().unwrap(), 1);
|
||||
}
|
||||
|
||||
fn smoke_threads() {
|
||||
let (tx, rx) = channel::<i32>();
|
||||
let _t = thread::spawn(move || {
|
||||
tx.send(1).unwrap();
|
||||
});
|
||||
assert_eq!(rx.recv().unwrap(), 1);
|
||||
}
|
||||
|
||||
fn smoke_port_gone() {
|
||||
let (tx, rx) = channel::<i32>();
|
||||
drop(rx);
|
||||
assert!(tx.send(1).is_err());
|
||||
}
|
||||
|
||||
pub fn test_all() {
|
||||
smoke();
|
||||
drop_full();
|
||||
drop_full_shared();
|
||||
smoke_shared();
|
||||
smoke_threads();
|
||||
smoke_port_gone();
|
||||
println!("mpsc test end");
|
||||
}
|
||||
}
|
@ -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<'_> {
|
||||
@ -110,7 +109,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)? };
|
||||
|
||||
@ -202,7 +201,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) {
|
||||
@ -272,8 +271,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)
|
||||
}
|
||||
|
||||
@ -296,14 +295,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);
|
||||
}
|
||||
|
||||
@ -323,26 +322,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 => {
|
||||
@ -351,8 +350,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -362,11 +361,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(),
|
||||
@ -375,7 +374,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(),
|
||||
@ -384,7 +383,7 @@ impl Syscall<'_> {
|
||||
);
|
||||
callbacks.push((1, thread::current().id(), epfd, *fd));
|
||||
}
|
||||
FileLike::EpollInstance(instance) => {
|
||||
FileLike::EpollInstance(_) => {
|
||||
return Err(SysError::EINVAL);
|
||||
}
|
||||
};
|
||||
@ -394,23 +393,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) {
|
||||
@ -425,13 +423,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;
|
||||
@ -454,13 +452,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);
|
||||
@ -611,7 +609,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)
|
||||
}
|
||||
@ -1150,10 +1148,6 @@ impl Process {
|
||||
"/proc/self/exe" => {
|
||||
return Ok(Arc::new(Pseudo::new(&self.exec_path, FileType::SymLink)));
|
||||
}
|
||||
"/dev/fb0" => {
|
||||
info!("/dev/fb0 will be opened");
|
||||
return Ok(Arc::new(Vga::default()));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
let (fd_dir_path, fd_name) = split_path(&path);
|
||||
@ -1579,7 +1573,7 @@ impl From<Metadata> for Stat {
|
||||
nlink: info.nlinks as u32,
|
||||
uid: info.uid as u32,
|
||||
gid: info.gid as u32,
|
||||
rdev: 0,
|
||||
rdev: info.rdev as u64,
|
||||
size: info.size as u64,
|
||||
blksize: info.blk_size as u32,
|
||||
blocks: info.blocks as u64,
|
||||
@ -1610,7 +1604,7 @@ impl From<Metadata> for Stat {
|
||||
nlink: info.nlinks as u32,
|
||||
uid: info.uid as u32,
|
||||
gid: info.gid as u32,
|
||||
rdev: 0,
|
||||
rdev: info.rdev as u64,
|
||||
size: info.size as u64,
|
||||
blksize: info.blk_size as u32,
|
||||
blocks: info.blocks as u64,
|
||||
@ -1729,8 +1723,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 {
|
||||
@ -1748,7 +1742,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));
|
||||
|
@ -1,15 +1,15 @@
|
||||
use rcore_memory::memory_set::handler::{Delay, File, Linear};
|
||||
use rcore_fs::vfs::MMapArea;
|
||||
use rcore_memory::memory_set::handler::Delay;
|
||||
use rcore_memory::memory_set::MemoryAttr;
|
||||
use rcore_memory::PAGE_SIZE;
|
||||
|
||||
use crate::memory::GlobalFrameAlloc;
|
||||
|
||||
use super::*;
|
||||
use crate::memory::GlobalFrameAlloc;
|
||||
|
||||
impl Syscall<'_> {
|
||||
pub fn sys_mmap(
|
||||
&mut self,
|
||||
mut addr: usize,
|
||||
addr: usize,
|
||||
len: usize,
|
||||
prot: usize,
|
||||
flags: usize,
|
||||
@ -24,6 +24,7 @@ impl Syscall<'_> {
|
||||
);
|
||||
|
||||
let mut proc = self.process();
|
||||
let mut addr = addr;
|
||||
if addr == 0 {
|
||||
// although NULL can be a valid address
|
||||
// but in C, NULL is regarded as allocation failure
|
||||
@ -49,49 +50,18 @@ impl Syscall<'_> {
|
||||
Delay::new(GlobalFrameAlloc),
|
||||
"mmap_anon",
|
||||
);
|
||||
return Ok(addr);
|
||||
Ok(addr)
|
||||
} else {
|
||||
let file = proc.get_file(fd)?;
|
||||
info!("mmap path is {} ", &*file.path);
|
||||
match &*file.path {
|
||||
"/dev/fb0" => {
|
||||
use crate::drivers::gpu::fb::FRAME_BUFFER;
|
||||
let attr = prot.to_attr();
|
||||
#[cfg(feature = "board_raspi3")]
|
||||
let attr = attr.mmio(crate::arch::paging::MMIOType::NormalNonCacheable as u8);
|
||||
|
||||
if let Some(fb) = FRAME_BUFFER.lock().as_ref() {
|
||||
self.vm().push(
|
||||
addr,
|
||||
addr + len,
|
||||
attr,
|
||||
Linear::new((fb.paddr() - addr) as isize),
|
||||
"mmap_file",
|
||||
);
|
||||
info!("mmap for /dev/fb0");
|
||||
return Ok(addr);
|
||||
} else {
|
||||
return Err(SysError::ENOENT);
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
let inode = file.inode();
|
||||
self.vm().push(
|
||||
addr,
|
||||
addr + len,
|
||||
prot.to_attr(),
|
||||
File {
|
||||
file: INodeForMap(inode),
|
||||
mem_start: addr,
|
||||
file_start: offset,
|
||||
file_end: offset + len,
|
||||
allocator: GlobalFrameAlloc,
|
||||
},
|
||||
"mmap_file",
|
||||
);
|
||||
return Ok(addr);
|
||||
}
|
||||
let file_like = proc.get_file_like(fd)?;
|
||||
let area = MMapArea {
|
||||
start_vaddr: addr,
|
||||
end_vaddr: addr + len,
|
||||
prot: prot.bits(),
|
||||
flags: flags.bits(),
|
||||
offset,
|
||||
};
|
||||
file_like.mmap(area)?;
|
||||
Ok(addr)
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,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
|
||||
@ -121,6 +91,7 @@ impl Syscall<'_> {
|
||||
Ok(0)
|
||||
}
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
pub struct MmapProt: usize {
|
||||
/// Data cannot be accessed
|
||||
@ -163,7 +134,7 @@ bitflags! {
|
||||
}
|
||||
|
||||
impl MmapProt {
|
||||
fn to_attr(self) -> MemoryAttr {
|
||||
pub fn to_attr(self) -> MemoryAttr {
|
||||
let mut attr = MemoryAttr::default().user();
|
||||
if self.contains(MmapProt::EXEC) {
|
||||
attr = attr.execute();
|
||||
|
@ -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 {
|
||||
|
@ -1 +1 @@
|
||||
nightly-2020-01-17
|
||||
nightly-2020-04-06
|
||||
|
2
user
2
user
@ -1 +1 @@
|
||||
Subproject commit 0aeea8f956884e8cfecb73a02fdaa5c287ae1b9d
|
||||
Subproject commit bb156ac8b60a4223da9871f7bfbd883f68f5b284
|
Loading…
Reference in New Issue
Block a user