signal的发送(暂时父子进程之间共享信号及相应的结构体) (#89)

* 解决由于spinlock.h中包含preempt_enable()带来的循环include问题

* new: 初步实现signal的数据结构

* new:signal相关数据结构

* fix: 解决bindings.rs报一堆警告的问题

* new: rust下的kdebug kinfo kwarn kBUG kerror宏

* 移动asm.h和cmpxchg.h

* new: signal的发送(暂时只支持父子进程共享信号及处理函数)
This commit is contained in:
login
2022-11-23 11:38:20 +08:00
committed by GitHub
parent 3d729e2069
commit 66f67c6a95
44 changed files with 1677 additions and 472 deletions

3
kernel/src/arch/mod.rs Normal file
View File

@ -0,0 +1,3 @@
#[cfg(target_arch="x86_64")]
#[macro_use]
pub mod x86_64;

View File

@ -0,0 +1,18 @@
use crate::include::bindings::bindings::process_control_block;
use core::{arch::asm, sync::atomic::compiler_fence};
/// @brief 获取指向当前进程的pcb的可变引用
#[inline]
pub fn current_pcb() -> &'static mut process_control_block {
let ret: Option<&mut process_control_block>;
unsafe {
let mut tmp: u64 = !(32767u64);
compiler_fence(core::sync::atomic::Ordering::SeqCst);
asm!("and {0}, rsp", inout(reg)(tmp),);
compiler_fence(core::sync::atomic::Ordering::SeqCst);
ret = (tmp as *mut process_control_block).as_mut();
}
ret.unwrap()
}

View File

@ -0,0 +1,24 @@
use core::arch::asm;
#[inline]
pub fn local_irq_save(flags: &mut u64) {
unsafe {
asm!(
"pushfq",
"pop rax",
"mov rax, {0}",
"cli",
out(reg)(*flags),
);
}
}
#[inline]
pub fn local_irq_restore(flags: &u64) {
let x = *flags;
unsafe {
asm!("push r15",
"popfq", in("r15")(x));
}
}

View File

@ -0,0 +1,3 @@
pub mod irqflags;
#[macro_use]
pub mod current;

View File

@ -0,0 +1,16 @@
use core::arch::asm;
/// @brief 获取当前cpu的apic id
#[inline]
pub fn arch_current_apic_id() -> u8 {
let cpuid_res: u32;
unsafe {
asm!(
"mov eax, 1",
"cpuid",
"mov r15, ebx",
lateout("r15") cpuid_res
);
}
return (cpuid_res >> 24) as u8;
}

View File

@ -1,6 +1,6 @@
#pragma once
#include <common/compiler.h>
#include <arch/x86_64/asm/asm.h>
#include <asm/asm.h>
/**
* @brief extern不存在的函数

View File

@ -1,5 +1,5 @@
#pragma once
#include <asm/asm.h>
// 保存当前rflags的值到变量x内并关闭中断
#define local_irq_save(x) __asm__ __volatile__("pushfq ; popq %0 ; cli" \
: "=g"(x)::"memory")

View File

@ -0,0 +1,3 @@
#[macro_use]
pub mod asm;
pub mod cpu;