Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.

Commit d7f1b56

Browse files
authored
Add doc for starry-core and apply missing_docs lint (#42)
* fix(doc): index page * doc: add docs for core * chore: update arceos * chore: different `missing_docs` lint level
1 parent 8eecede commit d7f1b56

File tree

7 files changed

+44
-15
lines changed

7 files changed

+44
-15
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export AX_LIB := axfeat
1010

1111
RUSTDOCFLAGS := -Z unstable-options --enable-index-page -D rustdoc::broken_intra_doc_links -D missing-docs
1212
EXTRA_CONFIG ?= $(PWD)/configs/$(ARCH).toml
13-
ifneq ($(filter $(MAKECMDGOALS),doc_check_missing),) # make doc_check_missing
13+
ifneq ($(filter $(MAKECMDGOALS),doc),) # make doc
1414
export RUSTDOCFLAGS
1515
else ifeq ($(filter $(MAKECMDGOALS),clean user_apps ax_root),) # Not make clean, user_apps, ax_root
1616
export AX_TESTCASES_LIST

api/src/imp/utils/time.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use arceos_posix_api::{self as api, ctypes::timeval};
22
use axerrno::LinuxResult;
33
use axhal::time::{monotonic_time_nanos, nanos_to_ticks};
4-
use starry_core::{task::time_stat_output, time::Tms};
4+
use starry_core::task::time_stat_output;
55

66
use crate::ptr::{PtrWrapper, UserPtr};
77

@@ -13,6 +13,18 @@ pub fn sys_get_time_of_day(ts: UserPtr<timeval>) -> LinuxResult<isize> {
1313
unsafe { Ok(api::sys_get_time_of_day(ts.get()?) as _) }
1414
}
1515

16+
#[repr(C)]
17+
pub struct Tms {
18+
/// 进程用户态执行时间,单位为us
19+
tms_utime: usize,
20+
/// 进程内核态执行时间,单位为us
21+
tms_stime: usize,
22+
/// 子进程用户态执行时间和,单位为us
23+
tms_cutime: usize,
24+
/// 子进程内核态执行时间和,单位为us
25+
tms_cstime: usize,
26+
}
27+
1628
pub fn sys_times(tms: UserPtr<Tms>) -> LinuxResult<isize> {
1729
let (_, utime_us, _, stime_us) = time_stat_output();
1830
unsafe {

api/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![no_std]
2+
#![allow(missing_docs)]
23

34
#[macro_use]
45
extern crate axlog;

core/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
//! The core functionality of a monolithic kernel, including loading user
2+
//! programs and managing processes.
3+
14
#![no_std]
5+
#![warn(missing_docs)]
26

37
#[macro_use]
48
extern crate axlog;
59
extern crate alloc;
610

711
pub mod mm;
812
pub mod task;
9-
pub mod time;
13+
mod time;

core/src/mm.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! User address space management.
2+
13
use core::ffi::CStr;
24

35
use alloc::{string::String, vec};
@@ -8,6 +10,7 @@ use kernel_elf_parser::{AuxvEntry, ELFParser, app_stack_region};
810
use memory_addr::{MemoryAddr, PAGE_SIZE_4K, VirtAddr};
911
use xmas_elf::{ElfFile, program::SegmentData};
1012

13+
/// Creates a new empty user address space.
1114
pub fn new_user_aspace_empty() -> AxResult<AddrSpace> {
1215
AddrSpace::new_empty(
1316
VirtAddr::from_usize(axconfig::plat::USER_SPACE_BASE),

core/src/task.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! User task management.
2+
13
use core::{
24
alloc::Layout,
35
cell::RefCell,
@@ -23,6 +25,7 @@ use weak_map::WeakMap;
2325

2426
use crate::time::TimeStat;
2527

28+
/// Create a new user task.
2629
pub fn new_user_task(
2730
name: &str,
2831
uctx: UspaceContext,
@@ -58,6 +61,7 @@ pub struct TaskExt {
5861
}
5962

6063
impl TaskExt {
64+
/// Create a new [`TaskExt`].
6165
pub fn new(thread: Arc<Thread>) -> Self {
6266
Self {
6367
time: RefCell::new(TimeStat::new()),
@@ -77,31 +81,36 @@ impl TaskExt {
7781
self.time.borrow().output()
7882
}
7983

84+
/// Get the [`ThreadData`] associated with this task.
8085
pub fn thread_data(&self) -> &ThreadData {
8186
self.thread.data().unwrap()
8287
}
8388

89+
/// Get the [`ProcessData`] associated with this task.
8490
pub fn process_data(&self) -> &ProcessData {
8591
self.thread.process().data().unwrap()
8692
}
8793
}
8894

8995
axtask::def_task_ext!(TaskExt);
9096

97+
/// Update the time statistics to reflect a switch from kernel mode to user mode.
9198
pub fn time_stat_from_kernel_to_user() {
9299
let curr_task = current();
93100
curr_task
94101
.task_ext()
95102
.time_stat_from_kernel_to_user(monotonic_time_nanos() as usize);
96103
}
97104

105+
/// Update the time statistics to reflect a switch from user mode to kernel mode.
98106
pub fn time_stat_from_user_to_kernel() {
99107
let curr_task = current();
100108
curr_task
101109
.task_ext()
102110
.time_stat_from_user_to_kernel(monotonic_time_nanos() as usize);
103111
}
104112

113+
/// Get the time statistics for the current task.
105114
pub fn time_stat_output() -> (usize, usize, usize, usize) {
106115
let curr_task = current();
107116
let (utime_ns, stime_ns) = curr_task.task_ext().time_stat_output();
@@ -113,6 +122,7 @@ pub fn time_stat_output() -> (usize, usize, usize, usize) {
113122
)
114123
}
115124

125+
/// Extended data for [`Thread`].
116126
pub struct ThreadData {
117127
/// The clear thread tid field
118128
///
@@ -123,23 +133,27 @@ pub struct ThreadData {
123133
}
124134

125135
impl ThreadData {
136+
/// Create a new [`ThreadData`].
126137
#[allow(clippy::new_without_default)]
127138
pub fn new() -> Self {
128139
Self {
129140
clear_child_tid: AtomicUsize::new(0),
130141
}
131142
}
132143

144+
/// Get the clear child tid field.
133145
pub fn clear_child_tid(&self) -> usize {
134146
self.clear_child_tid.load(Ordering::Relaxed)
135147
}
136148

149+
/// Set the clear child tid field.
137150
pub fn set_clear_child_tid(&self, clear_child_tid: usize) {
138151
self.clear_child_tid
139152
.store(clear_child_tid, Ordering::Relaxed);
140153
}
141154
}
142155

156+
/// Extended data for [`Process`].
143157
pub struct ProcessData {
144158
/// The executable path
145159
pub exe_path: RwLock<String>,
@@ -154,6 +168,7 @@ pub struct ProcessData {
154168
}
155169

156170
impl ProcessData {
171+
/// Create a new [`ProcessData`].
157172
pub fn new(exe_path: String, aspace: Arc<Mutex<AddrSpace>>) -> Self {
158173
Self {
159174
exe_path: RwLock::new(exe_path),
@@ -164,18 +179,22 @@ impl ProcessData {
164179
}
165180
}
166181

182+
/// Get the bottom address of the user heap.
167183
pub fn get_heap_bottom(&self) -> usize {
168184
self.heap_bottom.load(Ordering::Acquire)
169185
}
170186

187+
/// Set the bottom address of the user heap.
171188
pub fn set_heap_bottom(&self, bottom: usize) {
172189
self.heap_bottom.store(bottom, Ordering::Release)
173190
}
174191

192+
/// Get the top address of the user heap.
175193
pub fn get_heap_top(&self) -> usize {
176194
self.heap_top.load(Ordering::Acquire)
177195
}
178196

197+
/// Set the top address of the user heap.
179198
pub fn set_heap_top(&self, top: usize) {
180199
self.heap_top.store(top, Ordering::Release)
181200
}
@@ -221,6 +240,8 @@ static PROCESS_TABLE: RwLock<WeakMap<Pid, Weak<Process>>> = RwLock::new(WeakMap:
221240
static PROCESS_GROUP_TABLE: RwLock<WeakMap<Pid, Weak<ProcessGroup>>> = RwLock::new(WeakMap::new());
222241
static SESSION_TABLE: RwLock<WeakMap<Pid, Weak<Session>>> = RwLock::new(WeakMap::new());
223242

243+
/// Add the thread and possibly its process, process group and session to the
244+
/// corresponding tables.
224245
pub fn add_thread_to_table(thread: &Arc<Thread>) {
225246
let mut thread_table = THREAD_TABLE.write();
226247
thread_table.insert(thread.tid(), thread);

core/src/time.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
#[repr(C)]
2-
pub struct Tms {
3-
/// 进程用户态执行时间,单位为us
4-
pub tms_utime: usize,
5-
/// 进程内核态执行时间,单位为us
6-
pub tms_stime: usize,
7-
/// 子进程用户态执行时间和,单位为us
8-
pub tms_cutime: usize,
9-
/// 子进程内核态执行时间和,单位为us
10-
pub tms_cstime: usize,
11-
}
12-
131
numeric_enum_macro::numeric_enum! {
142
#[repr(i32)]
153
#[allow(non_camel_case_types)]

0 commit comments

Comments
 (0)