rename ucore to rcore

master
WangRunji 6 years ago
parent b8e32f8854
commit 2d5178d0b7

@ -53,7 +53,9 @@ install:
before_script: before_script:
- rustup component add rust-src - rustup component add rust-src
- (test -x $HOME/.cargo/bin/cargo-xbuild || cargo install cargo-xbuild) - (test -x $HOME/.cargo/bin/cargo-xbuild || cargo install cargo-xbuild)
- (test -x $HOME/.cargo/bin/bootimage || cargo install bootimage) - if [ $ARCH = x86_64 ]; then
(test -x $HOME/.cargo/bin/bootimage || cargo install bootimage);
fi
script: script:
- cd kernel && make build arch=$ARCH $OPTS && cd .. - cd kernel && make build arch=$ARCH $OPTS && cd ..

@ -1,5 +1,5 @@
[package] [package]
name = "ucore-memory" name = "rcore-memory"
version = "0.1.0" version = "0.1.0"
authors = ["WangRunji <wangrunji0408@163.com>"] authors = ["WangRunji <wangrunji0408@163.com>"]
edition = "2018" edition = "2018"

@ -1,5 +1,5 @@
[package] [package]
name = "ucore-process" name = "rcore-process"
version = "0.1.0" version = "0.1.0"
authors = ["WangRunji <wangrunji0408@163.com>"] authors = ["WangRunji <wangrunji0408@163.com>"]
edition = "2018" edition = "2018"

@ -1,5 +1,5 @@
[package] [package]
name = "ucore-sync" name = "sync-test"
version = "0.1.0" version = "0.1.0"
authors = ["WangRunji <wangrunji0408@163.com>"] authors = ["WangRunji <wangrunji0408@163.com>"]

1
kernel/.gitignore vendored

@ -1 +0,0 @@
outdir/

92
kernel/Cargo.lock generated

@ -203,6 +203,52 @@ dependencies = [
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "rcore"
version = "0.1.0"
dependencies = [
"aarch64 2.2.2 (git+https://github.com/equation314/aarch64)",
"apic 0.1.0 (git+https://github.com/wangrunji0408/APIC-Rust)",
"atags 0.1.0",
"bbl 0.1.0",
"bcm2837 0.1.0",
"bit-allocator 0.1.0",
"bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"bootloader 0.3.4 (git+https://github.com/wangrunji0408/bootloader)",
"cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"linked_list_allocator 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"once 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"pc-keyboard 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rcore-memory 0.1.0",
"rcore-process 0.1.0",
"riscv 0.3.0 (git+https://github.com/riscv-and-rust-and-decaf/riscv)",
"simple-filesystem 0.1.0 (git+https://github.com/wangrunji0408/SimpleFileSystem-Rust)",
"spin 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
"uart_16550 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"volatile 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"x86_64 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"xmas-elf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rcore-memory"
version = "0.1.0"
dependencies = [
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rcore-process"
version = "0.1.0"
dependencies = [
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"spin 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "register" name = "register"
version = "0.2.1" version = "0.2.1"
@ -303,52 +349,6 @@ dependencies = [
"x86_64 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "x86_64 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "ucore"
version = "0.1.0"
dependencies = [
"aarch64 2.2.2 (git+https://github.com/equation314/aarch64)",
"apic 0.1.0 (git+https://github.com/wangrunji0408/APIC-Rust)",
"atags 0.1.0",
"bbl 0.1.0",
"bcm2837 0.1.0",
"bit-allocator 0.1.0",
"bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"bootloader 0.3.4 (git+https://github.com/wangrunji0408/bootloader)",
"cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"linked_list_allocator 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"once 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"pc-keyboard 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"riscv 0.3.0 (git+https://github.com/riscv-and-rust-and-decaf/riscv)",
"simple-filesystem 0.1.0 (git+https://github.com/wangrunji0408/SimpleFileSystem-Rust)",
"spin 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
"uart_16550 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ucore-memory 0.1.0",
"ucore-process 0.1.0",
"volatile 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"x86_64 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"xmas-elf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ucore-memory"
version = "0.1.0"
dependencies = [
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ucore-process"
version = "0.1.0"
dependencies = [
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"spin 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "unicode-width" name = "unicode-width"
version = "0.1.5" version = "0.1.5"

@ -1,5 +1,5 @@
[package] [package]
name = "ucore" name = "rcore"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
authors = [ authors = [
@ -44,8 +44,8 @@ volatile = "0.2"
linked_list_allocator = "0.6" linked_list_allocator = "0.6"
lazy_static = { version = "1.2", features = ["spin_no_std"] } lazy_static = { version = "1.2", features = ["spin_no_std"] }
bit-allocator = { path = "../crate/bit-allocator" } bit-allocator = { path = "../crate/bit-allocator" }
ucore-memory = { path = "../crate/memory" } rcore-memory = { path = "../crate/memory" }
ucore-process = { path = "../crate/process" } rcore-process = { path = "../crate/process" }
simple-filesystem = { git = "https://github.com/wangrunji0408/SimpleFileSystem-Rust" } simple-filesystem = { git = "https://github.com/wangrunji0408/SimpleFileSystem-Rust" }
[target.'cfg(target_arch = "x86_64")'.dependencies] [target.'cfg(target_arch = "x86_64")'.dependencies]
@ -66,8 +66,8 @@ atags = { path = "../crate/atags" }
bcm2837 = { path = "../crate/bcm2837", optional = true } bcm2837 = { path = "../crate/bcm2837", optional = true }
[package.metadata.bootimage] [package.metadata.bootimage]
default-target = "x86_64-blog_os.json" default-target = "targets/x86_64.json"
output = "target/x86_64-blog_os/bootimage.bin" output = "target/x86_64/bootimage.bin"
minimum-image-size = 0 # The minimum output file size (in MiB) minimum-image-size = 0 # The minimum output file size (in MiB)
# The command invoked on `bootimage run` # The command invoked on `bootimage run`
# (the "{}" will be replaced with the path to the bootable disk image) # (the "{}" will be replaced with the path to the bootable disk image)

@ -28,7 +28,7 @@ smp ?= 4
m_mode ?= m_mode ?=
target := $(arch) target := $(arch)
kernel := target/$(target)/$(mode)/ucore kernel := target/$(target)/$(mode)/rcore
bin := target/$(target)/$(mode)/kernel.bin bin := target/$(target)/$(mode)/kernel.bin
bootimage := target/$(target)/bootimage.bin bootimage := target/$(target)/bootimage.bin
bbl_path := $(PWD)/../riscv-pk bbl_path := $(PWD)/../riscv-pk
@ -149,6 +149,7 @@ objcopy := $(prefix)objcopy
cc := $(prefix)gcc cc := $(prefix)gcc
as := $(prefix)as as := $(prefix)as
gdb := $(prefix)gdb gdb := $(prefix)gdb
export CC=$(cc)
.PHONY: all clean run build asm doc justrun debug kernel sfsimg install .PHONY: all clean run build asm doc justrun debug kernel sfsimg install
@ -220,11 +221,11 @@ else ifeq ($(arch), riscv32)
@-patch -p0 -N -b \ @-patch -p0 -N -b \
$(shell rustc --print sysroot)/lib/rustlib/src/rust/src/libcore/sync/atomic.rs \ $(shell rustc --print sysroot)/lib/rustlib/src/rust/src/libcore/sync/atomic.rs \
src/arch/riscv32/atomic.patch src/arch/riscv32/atomic.patch
@CC=$(cc) cargo xbuild $(build_args) @cargo xbuild $(build_args)
else ifeq ($(arch), riscv64) else ifeq ($(arch), riscv64)
@./build-rv64 @./build-rv64
else ifeq ($(arch), aarch64) else ifeq ($(arch), aarch64)
@CC=$(cc) cargo xbuild $(build_args) @cargo xbuild $(build_args)
endif endif

@ -1,10 +1,6 @@
#!/bin/bash #!/bin/bash
# The contents are adopted from xbuild verbose output. # The contents are adopted from xbuild verbose output.
# Output files are in target/${ARCH}-blog_os/debug # Output files are in target/${ARCH}/debug
#
# Usage:
# Just run
# $ ./run-qemu-script-custom-llc
# #
# By default riscv64 is built. To build for riscv32, # By default riscv64 is built. To build for riscv32,
# set the environment variable `RV32` to "1" # set the environment variable `RV32` to "1"
@ -12,12 +8,10 @@ set -e
if [[ ${RV32} = 1 ]]; then if [[ ${RV32} = 1 ]]; then
TARGET_ARCH=riscv32 TARGET_ARCH=riscv32
COMPILER_RT_CFLAGS="-march=rv32imac -mabi=ilp32 -O3" CFLAGS="-march=rv32imac -mabi=ilp32"
SFSIMG_CFLAGS="-march=rv32ia -mabi=ilp32"
else else
TARGET_ARCH=riscv64 TARGET_ARCH=riscv64
COMPILER_RT_CFLAGS="-march=rv64imac -mabi=lp64 -O3" CFLAGS="-march=rv64imac -mabi=lp64"
SFSIMG_CFLAGS="-march=rv64ia -mabi=lp64"
fi fi
UCORE_USER_IMAGE="../user/img/ucore-${TARGET_ARCH}.img" UCORE_USER_IMAGE="../user/img/ucore-${TARGET_ARCH}.img"
LLC=$PWD/../tools/llc LLC=$PWD/../tools/llc
@ -101,7 +95,7 @@ fi
CNAME=compiler_builtins CNAME=compiler_builtins
if ! [[ -f ${OUTDIR}/${CNAME}.o ]] if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
then then
rustc --crate-name compiler_builtins $CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.2/src/lib.rs \ rustc --crate-name compiler_builtins $CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.3/src/lib.rs \
--color always --crate-type lib --emit=metadata,llvm-bc \ --color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=3 \ -C opt-level=3 \
-C debuginfo=2 \ -C debuginfo=2 \
@ -396,10 +390,10 @@ rustc --edition=2018 --crate-name simple_filesystem $CARGO_PATH/git/checkouts/si
gen_full_rlib gen_full_rlib
fi fi
CNAME=ucore_process CNAME=rcore_process
if ! [[ -f ${OUTDIR}/${CNAME}.o ]] if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
then then
rustc --edition=2018 --crate-name ucore_process $PWD/../crate/process/src/lib.rs \ rustc --edition=2018 --crate-name rcore_process $PWD/../crate/process/src/lib.rs \
--color always --crate-type lib --emit=metadata,llvm-bc \ --color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \ -C opt-level=1 \
-C debuginfo=2 \ -C debuginfo=2 \
@ -412,10 +406,10 @@ rustc --edition=2018 --crate-name ucore_process $PWD/../crate/process/src/lib.rs
gen_full_rlib gen_full_rlib
fi fi
CNAME=ucore_memory CNAME=rcore_memory
if ! [[ -f ${OUTDIR}/${CNAME}.o ]] if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
then then
rustc --edition=2018 --crate-name ucore_memory $PWD/../crate/memory/src/lib.rs \ rustc --edition=2018 --crate-name rcore_memory $PWD/../crate/memory/src/lib.rs \
--color always --crate-type lib --emit=metadata,llvm-bc \ --color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \ -C opt-level=1 \
-C debuginfo=2 \ -C debuginfo=2 \
@ -498,7 +492,7 @@ fi
# Hand generate build.rs # Hand generate build.rs
if ! [[ -f ${OUTDIR}/libatomic_rt.a ]] if ! [[ -f ${OUTDIR}/libatomic_rt.a ]]
then then
${CC} src/arch/riscv32/compiler_rt.c ${COMPILER_RT_CFLAGS} -O3 -c -o ${OUTDIR}/compiler_rt.o ${CC} src/arch/riscv32/compiler_rt.c ${CFLAGS} -O3 -Wno-builtin-declaration-mismatch -c -o ${OUTDIR}/compiler_rt.o
${AR} r ${OUTDIR}/libatomic_rt.a ${OUTDIR}/compiler_rt.o ${AR} r ${OUTDIR}/libatomic_rt.a ${OUTDIR}/compiler_rt.o
fi fi
@ -513,7 +507,7 @@ _user_img_start:
.incbin "${UCORE_USER_IMAGE}" .incbin "${UCORE_USER_IMAGE}"
_user_img_end: _user_img_end:
EOF EOF
if ! ${CC} ${OUTDIR}/sfsimg.S ${SFSIMG_CFLAGS} -c -o ${OUTDIR}/sfsimg.o if ! ${CC} ${OUTDIR}/sfsimg.S ${CFLAGS} -c -o ${OUTDIR}/sfsimg.o
then then
echo "You should manually create sfs image!" echo "You should manually create sfs image!"
exit 1 exit 1
@ -524,7 +518,7 @@ fi
#make sfsimg #make sfsimg
CNAME=ucore CNAME=rcore
#if ! [[ -f ${OUTDIR}/${CNAME}.o ]] #if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
#then #then
if [[ ${board} = k210 ]]; then if [[ ${board} = k210 ]]; then
@ -533,7 +527,7 @@ if [[ ${board} = k210 ]]; then
else else
cp src/arch/riscv32/board/u540/linker.ld src/arch/riscv32/boot/linker64.ld cp src/arch/riscv32/board/u540/linker.ld src/arch/riscv32/boot/linker64.ld
fi fi
rustc --edition=2018 --crate-name ucore src/lib.rs \ rustc --edition=2018 --crate-name rcore src/lib.rs \
--color always --crate-type lib --emit=metadata,llvm-bc \ --color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \ -C opt-level=1 \
-C debuginfo=2 \ -C debuginfo=2 \
@ -553,8 +547,8 @@ rustc --edition=2018 --crate-name ucore src/lib.rs \
--extern riscv=${OUTDIR}/libriscv.rlib \ --extern riscv=${OUTDIR}/libriscv.rlib \
--extern simple_filesystem=${OUTDIR}/libsimple_filesystem.rlib \ --extern simple_filesystem=${OUTDIR}/libsimple_filesystem.rlib \
--extern spin=${OUTDIR}/libspin.rlib \ --extern spin=${OUTDIR}/libspin.rlib \
--extern ucore_memory=${OUTDIR}/libucore_memory.rlib \ --extern rcore_memory=${OUTDIR}/librcore_memory.rlib \
--extern ucore_process=${OUTDIR}/libucore_process.rlib \ --extern rcore_process=${OUTDIR}/librcore_process.rlib \
--extern volatile=${OUTDIR}/libvolatile.rlib \ --extern volatile=${OUTDIR}/libvolatile.rlib \
--extern xmas_elf=${OUTDIR}/libxmas_elf.rlib \ --extern xmas_elf=${OUTDIR}/libxmas_elf.rlib \
-L native=${OUTDIR} -l static=sfsimg -l static=atomic_rt -L native=${OUTDIR} -l static=sfsimg -l static=atomic_rt
@ -562,13 +556,13 @@ rustc --edition=2018 --crate-name ucore src/lib.rs \
gen_full_rlib gen_full_rlib
#fi #fi
#if ! [[ -f ${OUTDIR}/ucore ]] #if ! [[ -f ${OUTDIR}/rcore ]]
#then #then
if [[ ${board} = k210 ]]; then if [[ ${board} = k210 ]]; then
export LINK_K210='-L native=kendryte' export LINK_K210='-L native=kendryte'
fi fi
echo "rustc crate-type bin to ${TARGET_JSON}" echo "rustc crate-type bin to ${TARGET_JSON}"
rustc --edition=2018 --crate-name ucore src/main.rs \ rustc --edition=2018 --crate-name rcore src/main.rs \
--color always --crate-type bin --emit=link \ --color always --crate-type bin --emit=link \
-C opt-level=1 \ -C opt-level=1 \
-C debuginfo=2 \ -C debuginfo=2 \
@ -587,9 +581,9 @@ rustc --edition=2018 --crate-name ucore src/main.rs \
--extern riscv=${OUTDIR}/libriscv.rlib \ --extern riscv=${OUTDIR}/libriscv.rlib \
--extern simple_filesystem=${OUTDIR}/libsimple_filesystem.rlib \ --extern simple_filesystem=${OUTDIR}/libsimple_filesystem.rlib \
--extern spin=${OUTDIR}/libspin.rlib \ --extern spin=${OUTDIR}/libspin.rlib \
--extern ucore=${OUTDIR}/libucore.rlib \ --extern rcore=${OUTDIR}/librcore.rlib \
--extern ucore_memory=${OUTDIR}/libucore_memory.rlib \ --extern rcore_memory=${OUTDIR}/librcore_memory.rlib \
--extern ucore_process=${OUTDIR}/libucore_process.rlib \ --extern rcore_process=${OUTDIR}/librcore_process.rlib \
--extern volatile=${OUTDIR}/libvolatile.rlib \ --extern volatile=${OUTDIR}/libvolatile.rlib \
--extern xmas_elf=${OUTDIR}/libxmas_elf.rlib \ --extern xmas_elf=${OUTDIR}/libxmas_elf.rlib \
-L native=${OUTDIR} ${LINK_K210} -L native=${OUTDIR} ${LINK_K210}

@ -6,7 +6,7 @@ use aarch64::paging::{memory_attribute::*, PhysFrame as Frame};
use aarch64::{addr::*, barrier, regs::*}; use aarch64::{addr::*, barrier, regs::*};
use atags::atags::Atags; use atags::atags::Atags;
use log::*; use log::*;
use ucore_memory::PAGE_SIZE; use rcore_memory::PAGE_SIZE;
/// Memory initialization. /// Memory initialization.
pub fn init() { pub fn init() {

@ -1,5 +1,5 @@
//! Page table implementations for aarch64. //! Page table implementations for aarch64.
use ucore_memory::paging::*; use rcore_memory::paging::*;
use aarch64::asm::{tlb_invalidate, tlb_invalidate_all, ttbr_el1_read, ttbr_el1_write}; use aarch64::asm::{tlb_invalidate, tlb_invalidate_all, ttbr_el1_read, ttbr_el1_write};
use aarch64::{PhysAddr, VirtAddr}; use aarch64::{PhysAddr, VirtAddr};
use aarch64::paging::{Mapper, PageTable as Aarch64PageTable, PageTableEntry, PageTableFlags as EF, RecursivePageTable}; use aarch64::paging::{Mapper, PageTable as Aarch64PageTable, PageTableEntry, PageTableFlags as EF, RecursivePageTable};

@ -9,8 +9,8 @@ typedef unsigned u32;
// K210 doesn't support atomic operation on 0x40000000 (io port) // K210 doesn't support atomic operation on 0x40000000 (io port)
// We have to detect it and move it to 0x80000000 // We have to detect it and move it to 0x80000000
inline u32* fix_ptr32(u32 *ptr) { inline u32* fix_ptr32(u32 *ptr) {
return (u32)ptr < 0x80000000? return ptr < (u32*)0x80000000?
(u32*)((u32)ptr + 0x40000000): ptr + 0x40000000 / sizeof(u32):
ptr; ptr;
} }
@ -79,8 +79,8 @@ typedef unsigned long long u64;
// K210 doesn't support atomic operation on 0x40000000 (io port) // K210 doesn't support atomic operation on 0x40000000 (io port)
// We have to detect it and move it to 0x80000000 // We have to detect it and move it to 0x80000000
inline u64* fix_ptr64(u64 *ptr) { inline u64* fix_ptr64(u64 *ptr) {
return (u64)ptr < 0x80000000? return ptr < (u64*)0x80000000?
(u64*)((u64)ptr + 0x40000000): ptr + 0x40000000 / sizeof(u64):
ptr; ptr;
} }

@ -1,6 +1,6 @@
use core::mem; use core::mem;
use riscv::{addr::*, register::sstatus}; use riscv::{addr::*, register::sstatus};
use ucore_memory::PAGE_SIZE; use rcore_memory::PAGE_SIZE;
use log::*; use log::*;
use crate::memory::{FRAME_ALLOCATOR, init_heap, MemoryAttr, MemorySet, Linear}; use crate::memory::{FRAME_ALLOCATOR, init_heap, MemoryAttr, MemorySet, Linear};
use crate::consts::{MEMORY_OFFSET, MEMORY_END, KERN_VA_BASE}; use crate::consts::{MEMORY_OFFSET, MEMORY_END, KERN_VA_BASE};

@ -15,8 +15,6 @@ pub extern fn rust_main(hartid: usize, dtb: usize, hart_mask: usize, functions:
unsafe { cpu::set_cpu_id(hartid); } unsafe { cpu::set_cpu_id(hartid); }
if hartid != 0 { if hartid != 0 {
#[cfg(feature = "board_k210")]
loop {} // K210: if not, an assert will fail in spin::RwLock ???
while unsafe { !cpu::has_started(hartid) } { } while unsafe { !cpu::has_started(hartid) } { }
println!("Hello RISCV! in hart {}, dtb @ {:#x}, functions @ {:#x}", hartid, dtb, functions); println!("Hello RISCV! in hart {}, dtb @ {:#x}, functions @ {:#x}", hartid, dtb, functions);
others_main(); others_main();

@ -6,7 +6,7 @@ use riscv::asm::{sfence_vma, sfence_vma_all};
use riscv::paging::{Mapper, PageTable as RvPageTable, PageTableEntry, PageTableFlags as EF, RecursivePageTable}; use riscv::paging::{Mapper, PageTable as RvPageTable, PageTableEntry, PageTableFlags as EF, RecursivePageTable};
use riscv::paging::{FrameAllocator, FrameDeallocator}; use riscv::paging::{FrameAllocator, FrameDeallocator};
use riscv::register::satp; use riscv::register::satp;
use ucore_memory::paging::*; use rcore_memory::paging::*;
use log::*; use log::*;
#[cfg(target_arch = "riscv32")] #[cfg(target_arch = "riscv32")]
use crate::consts::KERNEL_P2_INDEX; use crate::consts::KERNEL_P2_INDEX;

@ -3,7 +3,7 @@ use crate::consts::KERNEL_OFFSET;
// Depends on kernel // Depends on kernel
use crate::memory::{FRAME_ALLOCATOR, init_heap, active_table}; use crate::memory::{FRAME_ALLOCATOR, init_heap, active_table};
use super::{BootInfo, MemoryRegionType}; use super::{BootInfo, MemoryRegionType};
use ucore_memory::paging::*; use rcore_memory::paging::*;
use once::*; use once::*;
use log::*; use log::*;

@ -1,6 +1,6 @@
// Depends on kernel // Depends on kernel
use crate::memory::{active_table, alloc_frame, dealloc_frame}; use crate::memory::{active_table, alloc_frame, dealloc_frame};
use ucore_memory::paging::*; use rcore_memory::paging::*;
use x86_64::instructions::tlb; use x86_64::instructions::tlb;
use x86_64::PhysAddr; use x86_64::PhysAddr;
use x86_64::registers::control::{Cr3, Cr3Flags}; use x86_64::registers::control::{Cr3, Cr3Flags};

@ -13,7 +13,7 @@
extern crate alloc; extern crate alloc;
pub use crate::process::{processor, new_kernel_context}; pub use crate::process::{processor, new_kernel_context};
use ucore_process::thread; use rcore_process::thread;
use linked_list_allocator::LockedHeap; use linked_list_allocator::LockedHeap;
#[macro_use] // print! #[macro_use] // print!

@ -3,4 +3,4 @@
#![cfg_attr(test, allow(dead_code, unused_macros, unused_imports))] #![cfg_attr(test, allow(dead_code, unused_macros, unused_imports))]
#[allow(unused_imports)] #[allow(unused_imports)]
use ucore; use rcore;

@ -2,9 +2,9 @@ pub use crate::arch::paging::*;
use bit_allocator::BitAlloc; use bit_allocator::BitAlloc;
use crate::consts::MEMORY_OFFSET; use crate::consts::MEMORY_OFFSET;
use super::HEAP_ALLOCATOR; use super::HEAP_ALLOCATOR;
use ucore_memory::*; use rcore_memory::*;
use ucore_memory::cow::CowExt; use rcore_memory::cow::CowExt;
pub use ucore_memory::memory_set::{MemoryArea, MemoryAttr, handler::*}; pub use rcore_memory::memory_set::{MemoryArea, MemoryAttr, handler::*};
use crate::process::{process}; use crate::process::{process};
use crate::sync::{SpinNoIrqLock, SpinNoIrq, MutexGuard}; use crate::sync::{SpinNoIrqLock, SpinNoIrq, MutexGuard};
use lazy_static::*; use lazy_static::*;
@ -12,10 +12,10 @@ use log::*;
use linked_list_allocator::LockedHeap; use linked_list_allocator::LockedHeap;
#[cfg(not(feature = "no_mmu"))] #[cfg(not(feature = "no_mmu"))]
pub type MemorySet = ucore_memory::memory_set::MemorySet<InactivePageTable0>; pub type MemorySet = rcore_memory::memory_set::MemorySet<InactivePageTable0>;
#[cfg(feature = "no_mmu")] #[cfg(feature = "no_mmu")]
pub type MemorySet = ucore_memory::no_mmu::MemorySet<NoMMUSupportImpl>; pub type MemorySet = rcore_memory::no_mmu::MemorySet<NoMMUSupportImpl>;
// x86_64 support up to 256M memory // x86_64 support up to 256M memory
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
@ -112,7 +112,7 @@ pub static MEMORY_ALLOCATOR: LockedHeap = LockedHeap::empty();
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub struct NoMMUSupportImpl; pub struct NoMMUSupportImpl;
impl ucore_memory::no_mmu::NoMMUSupport for NoMMUSupportImpl { impl rcore_memory::no_mmu::NoMMUSupport for NoMMUSupportImpl {
type Alloc = LockedHeap; type Alloc = LockedHeap;
fn allocator() -> &'static Self::Alloc { fn allocator() -> &'static Self::Alloc {
&MEMORY_ALLOCATOR &MEMORY_ALLOCATOR
@ -128,7 +128,7 @@ pub fn page_fault_handler(_addr: usize) -> bool {
//pub mod test { //pub mod test {
// pub fn cow() { // pub fn cow() {
// use super::*; // use super::*;
// use ucore_memory::cow::test::test_with; // use rcore_memory::cow::test::test_with;
// test_with(&mut active_table()); // test_with(&mut active_table());
// } // }
//} //}

@ -3,7 +3,7 @@ use alloc::{boxed::Box, collections::BTreeMap, string::String, sync::Arc, vec::V
use log::*; use log::*;
use simple_filesystem::file::File; use simple_filesystem::file::File;
use spin::Mutex; use spin::Mutex;
use ucore_process::Context; use rcore_process::Context;
use xmas_elf::{ElfFile, header, program::{Flags, Type}}; use xmas_elf::{ElfFile, header, program::{Flags, Type}};
use crate::arch::interrupt::{Context as ArchContext, TrapFrame}; use crate::arch::interrupt::{Context as ArchContext, TrapFrame};

@ -1,5 +1,5 @@
pub use self::context::Process; pub use self::context::Process;
pub use ucore_process::*; pub use rcore_process::*;
use crate::consts::{MAX_CPU_NUM, MAX_PROCESS_NUM}; use crate::consts::{MAX_CPU_NUM, MAX_PROCESS_NUM};
use crate::arch::cpu; use crate::arch::cpu;
use alloc::{boxed::Box, sync::Arc}; use alloc::{boxed::Box, sync::Arc};

6
user/Cargo.lock generated

@ -1,11 +1,11 @@
[[package]] [[package]]
name = "ucore-ulib" name = "rcore-ulib"
version = "0.1.0" version = "0.1.0"
[[package]] [[package]]
name = "ucore-user-programs" name = "rcore-user-programs"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"ucore-ulib 0.1.0", "rcore-ulib 0.1.0",
] ]

@ -1,8 +1,8 @@
[package] [package]
name = "ucore-user-programs" name = "rcore-user-programs"
version = "0.1.0" version = "0.1.0"
authors = ["Runji Wang <wangrunji0408@163.com>"] authors = ["Runji Wang <wangrunji0408@163.com>"]
edition = "2018" edition = "2018"
[dependencies] [dependencies]
"ucore-ulib" = { path = "ucore-ulib" } "rcore-ulib" = { path = "rcore-ulib" }

@ -4,7 +4,7 @@ arch ?= riscv32
mode ?= debug mode ?= debug
rust_src_dir := src/bin rust_src_dir := src/bin
rust_bin_path := target/$(arch)-ucore/$(mode) rust_bin_path := target/$(arch)-rcore/$(mode)
user_rust_bins := $(patsubst $(rust_src_dir)/%.rs, $(rust_bin_path)/%, $(wildcard $(rust_src_dir)/*.rs)) user_rust_bins := $(patsubst $(rust_src_dir)/%.rs, $(rust_bin_path)/%, $(wildcard $(rust_src_dir)/*.rs))
c_src_dir := c_src_dir :=
c_bin_path := c_bin_path :=
@ -17,7 +17,7 @@ sfsimg := $(build_path)/user-$(arch).img
mksfs := mksfs mksfs := mksfs
build_args := --target $(arch)-ucore.json build_args := --target targets/$(arch)-rcore.json
ifeq ($(mode), release) ifeq ($(mode), release)
build_args := $(build_args) --release build_args := $(build_args) --release
endif endif

@ -1,5 +1,5 @@
[package] [package]
name = "ucore-ulib" name = "rcore-ulib"
version = "0.1.0" version = "0.1.0"
authors = ["WangRunji <wangrunji0408@163.com>"] authors = ["WangRunji <wangrunji0408@163.com>"]
edition = "2018" edition = "2018"

@ -2,7 +2,7 @@
#![no_main] #![no_main]
#[macro_use] #[macro_use]
extern crate ucore_ulib; extern crate rcore_ulib;
macro_rules! color_text { macro_rules! color_text {
($text:expr, $color:expr) => {{ ($text:expr, $color:expr) => {{

@ -2,12 +2,12 @@
#![no_main] #![no_main]
#[macro_use] #[macro_use]
extern crate ucore_ulib; extern crate rcore_ulib;
// IMPORTANT: Must define main() like this // IMPORTANT: Must define main() like this
#[no_mangle] #[no_mangle]
pub fn main() { pub fn main() {
println!("Hello Rust uCore!"); println!("Hello Rust uCore!");
println!("I am process {}.", ucore_ulib::syscall::sys_getpid()); println!("I am process {}.", rcore_ulib::syscall::sys_getpid());
println!("hello pass."); println!("hello pass.");
} }

@ -2,9 +2,9 @@
#![no_main] #![no_main]
#[macro_use] #[macro_use]
extern crate ucore_ulib; extern crate rcore_ulib;
use ucore_ulib::io::getc; use rcore_ulib::io::getc;
use ucore_ulib::syscall::{sys_exec, sys_fork, sys_wait}; use rcore_ulib::syscall::{sys_exec, sys_fork, sys_wait};
pub fn get_line(buffer: &mut [u8]) -> usize { pub fn get_line(buffer: &mut [u8]) -> usize {
let mut pos: usize = 0; let mut pos: usize = 0;

@ -1,4 +0,0 @@
[[package]]
name = "ucore-ulib"
version = "0.1.0"
Loading…
Cancel
Save