Skip to content

Commit

Permalink
fix: optimize project source tree
Browse files Browse the repository at this point in the history
  • Loading branch information
yfblock committed Apr 16, 2024
1 parent 7c0b028 commit 989132f
Show file tree
Hide file tree
Showing 30 changed files with 32 additions and 176 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ packets.pcap
.gdb_history
kernel/*.lds
qemu.log
kernel/src/drivers.rs
kernel/src/drivers.rs
graph.png
46 changes: 2 additions & 44 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ LOG := error
BOARD:= qemu
RELEASE := release
QEMU_EXEC ?=
BUILD_ARGS :=
GDB ?= gdb-multiarch

BUS := device
Expand All @@ -31,6 +32,7 @@ else ifeq ($(ARCH), aarch64)
else ifeq ($(ARCH), loongarch64)
TARGET := loongarch64-unknown-none
QEMU_EXEC += qemu-system-$(ARCH) -kernel $(KERNEL_ELF)
BUILD_ARGS += -Z build-std
BUS := pci
else
$(error "ARCH" must be one of "x86_64", "riscv64", "aarch64" or "loongarch64")
Expand All @@ -50,7 +52,6 @@ QEMU_EXEC += -m 1G\
-smp 2 \
-D qemu.log -d in_asm,int,pcall,cpu_reset,guest_errors

BUILD_ARGS :=
ifeq ($(RELEASE), release)
BUILD_ARGS += --release
endif
Expand All @@ -77,7 +78,7 @@ endif
all: build

offline:
RUST_BACKTRACE=1 LOG=$(LOG) cargo build -Z build-std $(BUILD_ARGS) --features "$(features)" --offline
RUST_BACKTRACE=1 LOG=$(LOG) cargo build $(BUILD_ARGS) --features "$(features)" --offline
# cp $(SBI) sbi-qemu
# cp $(KERNEL_ELF) kernel-qemu
rust-objcopy --binary-architecture=riscv64 $(KERNEL_ELF) --strip-all -O binary os.bin
Expand All @@ -94,7 +95,7 @@ fs-img:
sudo umount $(FS_IMG)

build:
RUST_BACKTRACE=1 LOG=$(LOG) cargo build -Z build-std --target $(TARGET) $(BUILD_ARGS) --features "$(features)"
RUST_BACKTRACE=1 LOG=$(LOG) cargo build --target $(TARGET) $(BUILD_ARGS) --features "$(features)"
rust-objcopy --binary-architecture=$(ARCH) $(KERNEL_ELF) --strip-all -O binary $(KERNEL_BIN)

justbuild: fs-img build
Expand Down
7 changes: 1 addition & 6 deletions drivers/general-plic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,5 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
arch = { path = "../../arch" }
fdt = "0.1.5"
sync = { path = "../../modules/sync" }
kheader = { path = "../../modules/kheader" }
devices = { path = "../../modules/devices" }
frame_allocator = { path = "../../modules/frame_allocator" }
log = "0.4"
log = "0.4.11"
5 changes: 1 addition & 4 deletions drivers/general-plic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ extern crate alloc;
mod plic;

use alloc::sync::Arc;
use arch::VIRT_ADDR_START;
use devices::{
device::{DeviceType, Driver, IntDriver},
driver_define,
device::{DeviceType, Driver, IntDriver}, driver_define, fdt::node::FdtNode, VIRT_ADDR_START
};
use fdt::node::FdtNode;

pub struct PLIC {
base: usize,
Expand Down
3 changes: 0 additions & 3 deletions drivers/k210-sdcard/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
sync = { path = "../../modules/sync" }
devices = { path = "../../modules/devices" }
k210-pac = { git = "https://github.com/byte-os/k210-pac" }
k210-hal = { git = "https://github.com/byte-os/k210-hal" }
k210-soc = { git = "https://github.com/byte-os/k210-soc" }
log = "0.4"
logging = { path = "../../modules/logging" }
kheader = { path = "../../modules/kheader" }
4 changes: 1 addition & 3 deletions drivers/k210-sdcard/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ extern crate alloc;
use alloc::sync::Arc;
use core::{cell::RefCell, convert::TryInto};
use devices::{
device::{BlkDriver, DeviceType, Driver},
driver_define, DRIVERS_INIT,
device::{BlkDriver, DeviceType, Driver}, driver_define, Mutex, DRIVERS_INIT
};
use k210_hal::prelude::*;
use k210_pac::{Peripherals, SPI0};
Expand All @@ -25,7 +24,6 @@ use k210_soc::{
sysctl,
};
use log::info;
use sync::{LazyInit, Mutex};

pub struct SDCard<SPI> {
spi: SPI,
Expand Down
5 changes: 0 additions & 5 deletions drivers/kcvitek-sd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
arch = { path = "../../arch" }
fdt = "0.1.5"
sync = { path = "../../modules/sync" }
kheader = { path = "../../modules/kheader" }
devices = { path = "../../modules/devices" }
frame_allocator = { path = "../../modules/frame_allocator" }
log = "0.4"
cv1811-sd = { git = "https://github.com/Byte-OS/cv1811-sd.git" }
3 changes: 1 addition & 2 deletions drivers/kcvitek-sd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ use alloc::sync::Arc;
use cv1811_sd::clk_en;
use devices::{
device::{BlkDriver, DeviceType, Driver},
driver_define,
driver_define, fdt::node::FdtNode,
};
use fdt::node::FdtNode;

pub struct CvSd;

Expand Down
3 changes: 0 additions & 3 deletions drivers/kgoldfish-rtc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
arch = { path = "../../arch" }
fdt = "0.1.5"
kheader = { path = "../../modules/kheader" }
devices = { path = "../../modules/devices" }
log = "0.4"
timestamp = { git = "https://github.com/Byte-OS/timestamp.git" }
5 changes: 1 addition & 4 deletions drivers/kgoldfish-rtc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ extern crate alloc;
extern crate log;

use alloc::sync::Arc;
use arch::VIRT_ADDR_START;
use core::ptr::read_volatile;
use devices::{
device::{DeviceType, Driver, RtcDriver},
driver_define,
device::{DeviceType, Driver, RtcDriver}, driver_define, fdt::node::FdtNode, VIRT_ADDR_START
};
use fdt::node::FdtNode;
use timestamp::DateTime;

const TIMER_TIME_LOW: usize = 0x00;
Expand Down
5 changes: 0 additions & 5 deletions drivers/knvme/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
arch = { path = "../../arch" }
fdt = "0.1.5"
sync = { path = "../../modules/sync" }
kheader = { path = "../../modules/kheader" }
devices = { path = "../../modules/devices" }
frame_allocator = { path = "../../modules/frame_allocator" }
log = "0.4"
nvme_driver = { git = "https://github.com/rcore-os/nvme_driver", rev = "8ae0572" }
6 changes: 1 addition & 5 deletions drivers/knvme/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@ extern crate alloc;
extern crate log;

use alloc::{sync::Arc, vec::Vec};
use arch::{PAGE_SIZE, VIRT_ADDR_START};
use devices::{
device::{BlkDriver, DeviceType, Driver},
driver_define,
device::{BlkDriver, DeviceType, Driver}, driver_define, frame_alloc_much, FrameTracker, Mutex, PAGE_SIZE, VIRT_ADDR_START
};
use frame_allocator::{frame_alloc_much, FrameTracker};
use nvme_driver::{DmaAllocator, IrqController, NvmeInterface};
use sync::Mutex;

use core::ptr::write_volatile;

Expand Down
3 changes: 0 additions & 3 deletions drivers/kramdisk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,5 @@ edition = "2021"

[dependencies]
log = "0.4"
sync = { path = "../../modules/sync" }
virtio-drivers = { git = "https://github.com/rcore-os/virtio-drivers", rev = "61ece50"}
kheader = { path = "../../modules/kheader" }
devices = { path = "../../modules/devices" }
frame_allocator = { path = "../../modules/frame_allocator" }
5 changes: 0 additions & 5 deletions drivers/kvirtio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
arch = { path = "../../arch" }
fdt = "0.1.5"
log = "0.4"
sync = { path = "../../modules/sync" }
virtio-drivers = { git = "https://github.com/rcore-os/virtio-drivers", rev = "61ece50"}
kheader = { path = "../../modules/kheader" }
devices = { path = "../../modules/devices" }
frame_allocator = { path = "../../modules/frame_allocator" }
5 changes: 1 addition & 4 deletions drivers/kvirtio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@ pub mod virtio_net;
use core::ptr::NonNull;

use alloc::{sync::Arc, vec::Vec};
use arch::VIRT_ADDR_START;
use devices::{
device::{Driver, UnsupportedDriver},
driver_define, node_to_interrupts,
device::{Driver, UnsupportedDriver}, driver_define, fdt::node::FdtNode, node_to_interrupts, VIRT_ADDR_START
};
use fdt::node::FdtNode;
use virtio_drivers::transport::{
mmio::{MmioTransport, VirtIOHeader},
DeviceType, Transport,
Expand Down
3 changes: 1 addition & 2 deletions drivers/kvirtio/src/virtio_blk.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use alloc::sync::Arc;
use alloc::vec::Vec;
use devices::device::{BlkDriver, DeviceType, Driver};
use devices::register_device_irqs;
use sync::Mutex;
use devices::{register_device_irqs, Mutex};
use virtio_drivers::device::blk::VirtIOBlk;
use virtio_drivers::transport::Transport;

Expand Down
4 changes: 1 addition & 3 deletions drivers/kvirtio/src/virtio_impl.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use alloc::vec::Vec;
use arch::VIRT_ADDR_START;
use devices::{frame_alloc_much, FrameTracker, Mutex, VIRT_ADDR_START};
use core::ptr::NonNull;
use frame_allocator::{frame_alloc_much, FrameTracker};
use log::trace;
use sync::Mutex;
use virtio_drivers::{BufferDirection, Hal, PhysAddr};

static VIRTIO_CONTAINER: Mutex<Vec<FrameTracker>> = Mutex::new(Vec::new());
Expand Down
Loading

0 comments on commit 989132f

Please sign in to comment.