mirror of
https://github.com/panpaul/tiny_os
synced 2024-09-20 01:35:19 +08:00
feat: kernel/objects/tcb: add get_message_info
This commit is contained in:
parent
13180fe9f4
commit
8918dac00c
@ -6,6 +6,7 @@ use core::fmt::Debug;
|
||||
use core::sync::atomic::{AtomicUsize, Ordering};
|
||||
use uapi::cap::ObjectType;
|
||||
use uapi::fault::Fault;
|
||||
use uapi::syscall::*;
|
||||
use utils::{
|
||||
addr::*,
|
||||
linked_list::{Link, LinkHelper},
|
||||
@ -124,19 +125,6 @@ impl TcbObject {
|
||||
self.state
|
||||
}
|
||||
|
||||
pub fn tid(&self) -> usize {
|
||||
self.tid
|
||||
}
|
||||
|
||||
pub fn schedulable(&self) -> bool {
|
||||
matches!(self.state, ThreadState::Idle | ThreadState::Running)
|
||||
}
|
||||
|
||||
pub fn schedule_next(&self) {
|
||||
self.sched_queue.detach();
|
||||
SCHEDULER.add_next(self);
|
||||
}
|
||||
|
||||
pub fn set_state(&mut self, state: ThreadState) {
|
||||
self.state = state;
|
||||
}
|
||||
@ -157,6 +145,19 @@ impl TcbObject {
|
||||
self.time_tick = self.time_tick.saturating_sub(1);
|
||||
}
|
||||
|
||||
pub fn tid(&self) -> usize {
|
||||
self.tid
|
||||
}
|
||||
|
||||
pub fn schedulable(&self) -> bool {
|
||||
matches!(self.state, ThreadState::Idle | ThreadState::Running)
|
||||
}
|
||||
|
||||
pub fn schedule_next(&self) {
|
||||
self.sched_queue.detach();
|
||||
SCHEDULER.add_next(self);
|
||||
}
|
||||
|
||||
pub fn activate_vspace(&self) {
|
||||
let cap = TableCap::try_from(&self.vspace).expect("activate_vspace: invalid cap");
|
||||
let paddr = cap.as_object::<Level0>().paddr();
|
||||
@ -169,6 +170,10 @@ impl TcbObject {
|
||||
self.trapframe.handle_trap(false);
|
||||
}
|
||||
|
||||
pub fn get_message_info(&self) -> SysResult<MessageInfo> {
|
||||
MessageInfo::try_from(self.trapframe.get_reg(REG_MESSAGE_INFO))
|
||||
}
|
||||
|
||||
pub fn handle_syscall(&mut self) {
|
||||
// TODO: don't panic here, return error to user instead, create SysRespInfo
|
||||
handle_syscall(self).unwrap();
|
||||
|
@ -11,7 +11,7 @@ macro_rules! assert_length {
|
||||
}
|
||||
|
||||
pub fn handle_syscall(tcb: &mut TcbObject) -> SysResult {
|
||||
let info = MessageInfo::try_from(tcb.trapframe.get_reg(REG_MESSAGE_INFO))?;
|
||||
let info = tcb.get_message_info()?;
|
||||
|
||||
// Invalid, Debug*, Yield will bypass the capability check
|
||||
match info.label() {
|
||||
|
Loading…
Reference in New Issue
Block a user