Skip to content

Commit 8e1bb80

Browse files
committed
change ch4 test
1 parent ff927a9 commit 8e1bb80

File tree

5 files changed

+20
-26
lines changed

5 files changed

+20
-26
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ tools/
1616
pushall.sh
1717
*.bak
1818

19-
user/*
19+
ci-user/
20+
os/vendor/
21+
user/

os/src/mm/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub use frame_allocator::{frame_alloc, FrameTracker};
1818
pub use memory_set::remap_test;
1919
pub use memory_set::{kernel_stack_position, MapPermission, MemorySet, KERNEL_SPACE};
2020
pub use page_table::{translated_byte_buffer, PageTableEntry};
21-
use page_table::{PTEFlags, PageTable};
21+
pub use page_table::{PTEFlags, PageTable};
2222

2323
/// initiate heap allocator, frame allocator and kernel space
2424
pub fn init() {

os/src/mm/page_table.rs

+8
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@ use bitflags::*;
88
bitflags! {
99
/// page table entry flags
1010
pub struct PTEFlags: u8 {
11+
/// Valid
1112
const V = 1 << 0;
13+
/// Readable
1214
const R = 1 << 1;
15+
/// Writable
1316
const W = 1 << 2;
17+
/// eXecutable
1418
const X = 1 << 3;
19+
/// User
1520
const U = 1 << 4;
21+
/// Global
1622
const G = 1 << 5;
23+
/// Accessed
1724
const A = 1 << 6;
25+
/// Dirty
1826
const D = 1 << 7;
1927
}
2028
}

os/src/syscall/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,23 @@ const SYSCALL_SBRK: usize = 214;
2222
const SYSCALL_MUNMAP: usize = 215;
2323
/// mmap syscall
2424
const SYSCALL_MMAP: usize = 222;
25-
/// taskinfo syscall
26-
const SYSCALL_TASK_INFO: usize = 410;
25+
/// trace syscall
26+
const SYSCALL_TRACE: usize = 410;
2727

2828
mod fs;
2929
mod process;
3030

3131
use fs::*;
3232
use process::*;
33+
3334
/// handle syscall exception with `syscall_id` and other arguments
3435
pub fn syscall(syscall_id: usize, args: [usize; 3]) -> isize {
3536
match syscall_id {
3637
SYSCALL_WRITE => sys_write(args[0], args[1] as *const u8, args[2]),
3738
SYSCALL_EXIT => sys_exit(args[0] as i32),
3839
SYSCALL_YIELD => sys_yield(),
3940
SYSCALL_GET_TIME => sys_get_time(args[0] as *mut TimeVal, args[1]),
40-
SYSCALL_TASK_INFO => sys_task_info(args[0] as *mut TaskInfo),
41+
SYSCALL_TRACE => sys_trace(args[0], args[1], args[2]),
4142
SYSCALL_MMAP => sys_mmap(args[0], args[1], args[2]),
4243
SYSCALL_MUNMAP => sys_munmap(args[0], args[1]),
4344
SYSCALL_SBRK => sys_sbrk(args[0] as i32),

os/src/syscall/process.rs

+4-21
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
//! Process management syscalls
2-
use crate::{
3-
config::MAX_SYSCALL_NUM,
4-
task::{
5-
change_program_brk, exit_current_and_run_next, suspend_current_and_run_next, TaskStatus,
6-
},
7-
};
2+
use crate::task::{change_program_brk, exit_current_and_run_next, suspend_current_and_run_next};
83

94
#[repr(C)]
105
#[derive(Debug)]
@@ -13,17 +8,6 @@ pub struct TimeVal {
138
pub usec: usize,
149
}
1510

16-
/// Task information
17-
#[allow(dead_code)]
18-
pub struct TaskInfo {
19-
/// Task status in it's life cycle
20-
status: TaskStatus,
21-
/// The numbers of syscall called by task
22-
syscall_times: [u32; MAX_SYSCALL_NUM],
23-
/// Total running time of task
24-
time: usize,
25-
}
26-
2711
/// task exits and submit an exit code
2812
pub fn sys_exit(_exit_code: i32) -> ! {
2913
trace!("kernel: sys_exit");
@@ -46,11 +30,10 @@ pub fn sys_get_time(_ts: *mut TimeVal, _tz: usize) -> isize {
4630
-1
4731
}
4832

49-
/// YOUR JOB: Finish sys_task_info to pass testcases
33+
/// TODO: Finish sys_trace to pass testcases
5034
/// HINT: You might reimplement it with virtual memory management.
51-
/// HINT: What if [`TaskInfo`] is splitted by two pages ?
52-
pub fn sys_task_info(_ti: *mut TaskInfo) -> isize {
53-
trace!("kernel: sys_task_info NOT IMPLEMENTED YET!");
35+
pub fn sys_trace(_trace_request: usize, _id: usize, _data: usize) -> isize {
36+
trace!("kernel: sys_trace");
5437
-1
5538
}
5639

0 commit comments

Comments
 (0)