Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion os/StarryOS/configs/board/licheerv-nano-sg2002.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
env = { UIMAGE = "y" }
features = [
"sg2002",
"myplat",
]
log = "Info"
plat_dyn = false
Expand Down
1 change: 0 additions & 1 deletion os/StarryOS/kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ ax-alloc = { workspace = true, features = ["default"] }
ax-config.workspace = true
ax-display.workspace = true
ax-fs = { version = "0.5.15", path = "../../arceos/modules/axfs-ng", package = "ax-fs-ng" }
ax-hal.workspace = true
ax-input = { workspace = true, optional = true }
ax-lazyinit.workspace = true
ax-log.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion os/StarryOS/kernel/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloc::{
};

use ax_fs::FS_CONTEXT;
use ax_hal::uspace::UserContext;
use ax_runtime::hal::cpu::uspace::UserContext;
use ax_sync::Mutex;
use ax_task::{AxTaskExt, spawn_task};
use starry_process::{Pid, Process};
Expand Down
2 changes: 1 addition & 1 deletion os/StarryOS/kernel/src/file/memfd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ use core::{

use ax_errno::{AxError, AxResult};
use ax_fs::FileFlags;
use ax_hal::paging::MappingFlags;
use ax_io::{IoBuf, SeekFrom, prelude::*};
use ax_memory_addr::VirtAddr;
use ax_memory_set::MemoryArea;
use ax_runtime::hal::paging::MappingFlags;
use ax_sync::Mutex;
use axpoll::{IoEvents, Pollable};

Expand Down
2 changes: 1 addition & 1 deletion os/StarryOS/kernel/src/file/timerfd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use core::{
};

use ax_errno::{AxError, AxResult};
use ax_hal::time::{TimeValue, monotonic_time, wall_time};
use ax_runtime::hal::time::{TimeValue, monotonic_time, wall_time};
use ax_sync::Mutex;
use ax_task::future::{block_on, poll_io, timeout_at};
use axpoll::{IoEvents, PollSet, Pollable};
Expand Down
13 changes: 8 additions & 5 deletions os/StarryOS/kernel/src/mm/access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ use core::{
};

use ax_errno::{AxError, AxResult};
use ax_hal::{asm::user_copy, paging::MappingFlags, trap::page_fault_handler};
use ax_io::prelude::*;
use ax_memory_addr::{MemoryAddr, PAGE_SIZE_4K, VirtAddr};
use ax_runtime::hal::{
cpu::{asm::user_copy, trap::page_fault_handler},
paging::MappingFlags,
};
use ax_task::{current, might_sleep};
use extern_trait::extern_trait;
use starry_vm::{VmError, VmIo, VmResult, vm_load_until_nul, vm_read_slice, vm_write_slice};
Expand All @@ -25,7 +28,7 @@ use crate::{
#[track_caller]
pub fn access_user_memory<R>(f: impl FnOnce() -> R) -> R {
assert!(
ax_hal::asm::irqs_enabled(),
ax_runtime::hal::cpu::asm::irqs_enabled(),
"faultable user memory access requires IRQs enabled"
);

Expand Down Expand Up @@ -508,7 +511,7 @@ pub fn write_kernel_text(addr: VirtAddr, data: &[u8]) -> AxResult<()> {
}

#[cfg(target_arch = "aarch64")]
ax_hal::asm::clean_dcache_range_to_pou(addr, data.len());
ax_runtime::hal::cpu::asm::clean_dcache_range_to_pou(addr, data.len());

guard.protect(aligned_addr, aligned_length, original_flags)?;
Ok(())
Expand All @@ -519,12 +522,12 @@ pub fn write_kernel_text(addr: VirtAddr, data: &[u8]) -> AxResult<()> {

fn flush_tlb_range(start: VirtAddr, size: usize) {
for offset in (0..size).step_by(PAGE_SIZE_4K) {
ax_hal::asm::flush_tlb(Some(start + offset));
ax_runtime::hal::cpu::asm::flush_tlb(Some(start + offset));
}
}

fn sync_modified_kernel_text(start: VirtAddr, size: usize) {
flush_tlb_range(start, size);

ax_hal::asm::flush_icache_all();
ax_runtime::hal::cpu::asm::flush_icache_all();
}
6 changes: 3 additions & 3 deletions os/StarryOS/kernel/src/mm/aspace/backend/cow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use core::slice;

use ax_errno::{AxError, AxResult};
use ax_fs::FileBackend;
use ax_hal::{
use ax_kspin::SpinNoIrq;
use ax_memory_addr::{MemoryAddr, PAGE_SIZE_4K, PhysAddr, VirtAddr, VirtAddrRange, align_down_4k};
use ax_runtime::hal::{
mem::phys_to_virt,
paging::{MappingFlags, PageSize, PageTableCursor, PagingError},
};
use ax_kspin::SpinNoIrq;
use ax_memory_addr::{MemoryAddr, PAGE_SIZE_4K, PhysAddr, VirtAddr, VirtAddrRange, align_down_4k};
use ax_sync::Mutex;

use super::{
Expand Down
2 changes: 1 addition & 1 deletion os/StarryOS/kernel/src/mm/aspace/backend/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use core::sync::atomic::{AtomicUsize, Ordering};

use ax_errno::{AxError, AxResult};
use ax_fs::{CachedFile, FileFlags};
use ax_hal::paging::{MappingFlags, PageSize, PageTableCursor, PagingError};
use ax_memory_addr::{PAGE_SIZE_4K, VirtAddr, VirtAddrRange};
use ax_runtime::hal::paging::{MappingFlags, PageSize, PageTableCursor, PagingError};
use ax_sync::Mutex;
use axfs_ng_vfs::Location;
use weak_map::StrongRef;
Expand Down
2 changes: 1 addition & 1 deletion os/StarryOS/kernel/src/mm/aspace/backend/linear.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use alloc::sync::Arc;

use ax_errno::AxResult;
use ax_hal::paging::{MappingFlags, PageSize, PageTableCursor, PagingError};
use ax_memory_addr::{PhysAddr, PhysAddrRange, VirtAddr, VirtAddrRange};
use ax_runtime::hal::paging::{MappingFlags, PageSize, PageTableCursor, PagingError};
use ax_sync::Mutex;

use super::{AddrSpace, Backend, BackendOps, pages_in};
Expand Down
6 changes: 3 additions & 3 deletions os/StarryOS/kernel/src/mm/aspace/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use alloc::{

use ax_alloc::{UsageKind, global_allocator};
use ax_errno::{AxError, AxResult};
use ax_hal::{
use ax_memory_addr::{DynPageIter, PAGE_SIZE_4K, PhysAddr, VirtAddr, VirtAddrRange};
use ax_memory_set::MappingBackend;
use ax_runtime::hal::{
mem::{phys_to_virt, virt_to_phys},
paging::{MappingFlags, PageSize, PageTable, PageTableCursor},
};
use ax_memory_addr::{DynPageIter, PAGE_SIZE_4K, PhysAddr, VirtAddr, VirtAddrRange};
use ax_memory_set::MappingBackend;
use ax_sync::Mutex;
use enum_dispatch::enum_dispatch;

Expand Down
2 changes: 1 addition & 1 deletion os/StarryOS/kernel/src/mm/aspace/backend/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use alloc::{sync::Arc, vec::Vec};
use core::ops::Deref;

use ax_errno::AxResult;
use ax_hal::paging::{MappingFlags, PageSize, PageTableCursor, PagingError};
use ax_memory_addr::{MemoryAddr, PhysAddr, VirtAddr, VirtAddrRange};
use ax_runtime::hal::paging::{MappingFlags, PageSize, PageTableCursor, PagingError};
use ax_sync::Mutex;

use super::{AddrSpace, Backend, BackendOps, alloc_frame, dealloc_frame, divide_page, pages_in};
Expand Down
10 changes: 5 additions & 5 deletions os/StarryOS/kernel/src/mm/aspace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ use core::{
};

use ax_errno::{AxError, AxResult, ax_bail};
use ax_hal::{
mem::phys_to_virt,
paging::{MappingFlags, PageSize, PageTable, PageTableCursor},
trap::PageFaultFlags,
};
use ax_memory_addr::{
MemoryAddr, PAGE_SIZE_4K, PageIter4K, PhysAddr, VirtAddr, VirtAddrRange, is_aligned_4k,
};
use ax_memory_set::{MemoryArea, MemorySet};
use ax_runtime::hal::{
mem::phys_to_virt,
paging::{MappingFlags, PageSize, PageTable, PageTableCursor},
trap::PageFaultFlags,
};
use ax_sync::Mutex;

mod backend;
Expand Down
4 changes: 2 additions & 2 deletions os/StarryOS/kernel/src/mm/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use core::{ffi::CStr, iter};

use ax_errno::{AxError, AxResult};
use ax_fs::{CachedFile, FS_CONTEXT, FileBackend};
use ax_hal::{
use ax_memory_addr::{MemoryAddr, PAGE_SIZE_4K, VirtAddr};
use ax_runtime::hal::{
mem::virt_to_phys,
paging::{MappingFlags, PageSize},
};
use ax_memory_addr::{MemoryAddr, PAGE_SIZE_4K, VirtAddr};
use ax_sync::Mutex;
use axfs_ng_vfs::Location;
use kernel_elf_parser::{
Expand Down
6 changes: 3 additions & 3 deletions os/StarryOS/kernel/src/pseudofs/dev/card0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ use core::{
task::Context,
};

use ax_hal::{mem::virt_to_phys, paging::PageSize, time::monotonic_time};
use ax_memory_addr::{PhysAddr, PhysAddrRange, VirtAddr};
use ax_runtime::hal::{mem::virt_to_phys, paging::PageSize, time::monotonic_time};
use ax_sync::Mutex;
use axfs_ng_vfs::{NodeFlags, VfsError, VfsResult};
use axpoll::{IoEvents, PollSet, Pollable};
Expand Down Expand Up @@ -490,7 +490,7 @@ impl Card0 {

fn dealloc_dumb_pages(&self, paddr: PhysAddr, size: usize) {
use ax_alloc::{UsageKind, global_allocator};
use ax_hal::mem::phys_to_virt;
use ax_runtime::hal::mem::phys_to_virt;
let vaddr = phys_to_virt(paddr);
let num_pages = size / (PageSize::Size4K as usize);
global_allocator().dealloc_pages(vaddr.as_usize(), num_pages, UsageKind::VirtMem);
Expand All @@ -511,7 +511,7 @@ impl Card0 {
let info = ax_display::framebuffer_info();
let src_size = buf.size.min(info.fb_size as u64) as usize;
if let Some(src_paddr) = buf.paddr {
use ax_hal::mem::phys_to_virt;
use ax_runtime::hal::mem::phys_to_virt;
let src = phys_to_virt(src_paddr);
let dst = VirtAddr::from(info.fb_base_vaddr);
let copy_bytes = src_size.min(info.fb_size);
Expand Down
2 changes: 1 addition & 1 deletion os/StarryOS/kernel/src/pseudofs/dev/card1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use core::{

use ax_driver::rknpu::{self, RknpuAction, RknpuMemCreate, RknpuMemMap, RknpuMemSync, RknpuSubmit};
use ax_errno::{AxError, AxResult};
use ax_hal::mem::virt_to_phys;
use ax_memory_addr::PhysAddrRange;
use ax_runtime::hal::mem::virt_to_phys;
use axfs_ng_vfs::{DeviceId, NodeFlags, VfsError, VfsResult};
use axpoll::{IoEvents, Pollable};
use linux_raw_sys::general::O_CLOEXEC;
Expand Down
12 changes: 6 additions & 6 deletions os/StarryOS/kernel/src/pseudofs/dev/cvi_camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use alloc::{collections::vec_deque::VecDeque, vec::Vec};
use core::{any::Any, time::Duration};

use ax_errno::{AxError, LinuxError};
use ax_hal::mem::phys_to_virt;
use ax_kspin::SpinNoIrq as Mutex;
use ax_memory_addr::PhysAddr;
use ax_runtime::hal::mem::phys_to_virt;
use ax_task::sleep;
use axfs_ng_vfs::{NodeFlags, VfsResult};
use sg200x_bsp::{
Expand Down Expand Up @@ -219,7 +219,7 @@ impl<T: UartTransport> CameraProtocol<T> {
fn read_slip_frame(&mut self, timeout_ms: u64) -> Result<Vec<u8>, CameraError> {
use core::time::Duration;

use ax_hal::time::wall_time;
use ax_runtime::hal::time::wall_time;
let deadline = wall_time() + Duration::from_millis(timeout_ms);
let mut tmp = [0u8; 0x1200];
loop {
Expand Down Expand Up @@ -321,7 +321,7 @@ impl UartTransport for Uart3 {

fn read_bytes(&mut self, buf: &mut [u8], _timeout_ms: u64) -> Result<usize, CameraError> {
sleep(Duration::from_millis(3));
ax_hal::irq::set_enable(47, false);
ax_runtime::hal::irq::set_enable(47, false);
let n = {
let mut cache_buf = CAMERA_UART_BUF.lock();
let n = cache_buf.len().min(buf.len());
Expand All @@ -336,7 +336,7 @@ impl UartTransport for Uart3 {
// Always re-enable the IRQ before returning, otherwise the ESP32's
// reply traffic stops landing in CAMERA_UART_BUF and every subsequent
// poll sees an empty queue forever.
ax_hal::irq::set_enable(47, true);
ax_runtime::hal::irq::set_enable(47, true);
if n == 0 {
sleep(Duration::from_millis(1));
}
Expand Down Expand Up @@ -373,7 +373,7 @@ impl CviCamera {
dw_apb_uart::DW8250::new(phys_to_virt(PhysAddr::from(UART3_ADDR)).as_usize());
uart3.init_with_baud(1500000);
uart3.set_ier(true);
ax_hal::irq::register(47, |_irq| {
ax_runtime::hal::irq::register(47, |_irq| {
let mut uart3 =
dw_apb_uart::DW8250::new(phys_to_virt(PhysAddr::from(UART3_ADDR)).as_usize());
let mut buf = CAMERA_UART_BUF.lock();
Expand All @@ -386,7 +386,7 @@ impl CviCamera {
}
uart3.set_ier(true);
});
ax_hal::irq::set_enable(47, true);
ax_runtime::hal::irq::set_enable(47, true);
Self {
inner: Mutex::new(CameraProtocol::new_default(Uart3)),
}
Expand Down
6 changes: 3 additions & 3 deletions os/StarryOS/kernel/src/pseudofs/dev/cvi_usb_camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use core::{any::Any, time::Duration};

use ax_config::plat::PHYS_VIRT_OFFSET;
use ax_errno::AxError;
use ax_hal::{
use ax_kspin::SpinNoIrq as Mutex;
use ax_memory_addr::{PhysAddr, VirtAddr};
use ax_runtime::hal::{
mem::{phys_to_virt, virt_to_phys},
time::busy_wait,
};
use ax_kspin::SpinNoIrq as Mutex;
use ax_memory_addr::{PhysAddr, VirtAddr};
use axfs_ng_vfs::{NodeFlags, VfsResult};
use sg200x_bsp::{
gpio::{Direction, GPIO, GPIO1_BASE},
Expand Down
2 changes: 1 addition & 1 deletion os/StarryOS/kernel/src/pseudofs/dev/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ pub fn input_device_count() -> u32 {
}

use ax_errno::{AxError, AxResult};
use ax_hal::time::wall_time;
use ax_input::{ErasedInputDevice, Event, EventType, InputDevice, InputDeviceId, InputError};
use ax_runtime::hal::time::wall_time;
use ax_sync::Mutex;
use axfs_ng_vfs::{DeviceId, NodeFlags, NodeType, VfsResult};
use axpoll::{IoEvents, Pollable};
Expand Down
2 changes: 1 addition & 1 deletion os/StarryOS/kernel/src/pseudofs/dev/fb.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use core::{any::Any, slice};

use ax_errno::AxError;
use ax_hal::mem::virt_to_phys;
use ax_memory_addr::{PhysAddrRange, VirtAddr};
use ax_runtime::hal::mem::virt_to_phys;
use axfs_ng_vfs::{NodeFlags, VfsError, VfsResult};
use starry_vm::VmMutPtr;

Expand Down
2 changes: 1 addition & 1 deletion os/StarryOS/kernel/src/pseudofs/dev/rknpu_card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use core::{
ffi::{c_char, c_ulong},
};

use ax_hal::asm::user_copy;
use ax_runtime::hal::cpu::asm::user_copy;
use axfs_ng_vfs::{DeviceId, NodeFlags, VfsError, VfsResult};

use super::rknpu_drm::DrmVersion;
Expand Down
Loading
Loading