mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-08 22:36:48 +00:00
* 几个结构体 * 通过vmx_init以及create_vm,create_vcpu部分TODO * kvm_run完成一半 * 能够成功vmlaunch,但是在vmexit时候还有些问题未排查出来 * 解决了vmlaunch导致的cpu_reset的问题 * 整理代码 * 暂时性push到hyc仓库 * 修改内存虚拟化部分参数传入,解决死锁问题 * 初步完成ept映射.但不停EPT_VIOLATION * 初步完成了EPT映射,但是读写内存还是有点问题 * fixme * 更新了一些truncate到from_bits_unchecked的实现 * 完成内存虚拟化EPT_VIOLATION的映射 * fmt * Remove /fixme from .gitignore * Remove /fixme file * Update kernel/src/init/init.rs Co-authored-by: Samuel Dai <samuka007@dragonos.org> * Update kernel/src/init/init.rs Co-authored-by: Samuel Dai <samuka007@dragonos.org> * 修改了注释格式,删除了附带的一些文件操作 * feat(syscall): 实现syscall restart (#1075) 能够在系统调用返回ERESTARTSYS时,信号处理结束后,自动重启系统调用. TODO: 实现wait等需要restart_block的系统调用的重启 Signed-off-by: longjin <longjin@DragonOS.org> * chore: update docker image version in script && update doc (#1076) * chore: update docker image version in script * chore: replace lots of spaces with newline in doc * fix: 修复wait4系统调用部分语义与Linux不一致的问题 (#1080) * fix: 修复wait4系统调用部分语义与Linux不一致的问题 解决wait不住/wait之后卡死的bug --------- Signed-off-by: longjin <longjin@DragonOS.org> * feat(fs/syscall): 实现fchdir系统调用 (#1081) Signed-off-by: longjin <longjin@DragonOS.org> * fix(mm): 修复fat文件系统的PageCache同步问题 (#1005) --------- Co-authored-by: longjin <longjin@DragonOS.org> * fix: 修正nographic启动时,控制台日志未能输出到文件的问题 (#1082) Signed-off-by: longjin <longjin@DragonOS.org> * fix(process): 修复copy_process的一些bug & 支持默认init进程传参 (#1083) - 修复`copy_process`函数对标志位处理不正确的bug - init进程搜索列表中,支持为默认init程序传入参数 Signed-off-by: longjin <longjin@DragonOS.org> * feat: 完善sys_reboot (#1084) * fix(process): 修复copy_process的一些bug & 支持默认init进程传参 - 修复`copy_process`函数对标志位处理不正确的bug - init进程搜索列表中,支持为默认init程序传入参数 Signed-off-by: longjin <longjin@DragonOS.org> * feat: 完善sys_reboot - 校验magic number - 支持多个cmd (具体内容未实现) Signed-off-by: longjin <longjin@DragonOS.org> --------- Signed-off-by: longjin <longjin@DragonOS.org> * fix: 修复do_wait函数在wait所有子进程时,忘了释放锁就sleep的bug (#1089) Signed-off-by: longjin <longjin@DragonOS.org> * pull主线并且fmt --------- Signed-off-by: longjin <longjin@DragonOS.org> Co-authored-by: GnoCiYeH <heyicong@dragonos.org> Co-authored-by: Samuel Dai <samuka007@dragonos.org> Co-authored-by: LoGin <longjin@DragonOS.org> Co-authored-by: LIU Yuwei <22045841+Marsman1996@users.noreply.github.com> Co-authored-by: MemoryShore <1353318529@qq.com>
143 lines
3.3 KiB
Rust
143 lines
3.3 KiB
Rust
use core::ops::BitAnd;
|
|
|
|
use alloc::vec::Vec;
|
|
|
|
use crate::{bitmap_core::BitMapCore, traits::BitMapOps};
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct AllocBitmap {
|
|
elements: usize,
|
|
data: Vec<usize>,
|
|
core: BitMapCore<usize>,
|
|
}
|
|
|
|
impl AllocBitmap {
|
|
pub fn new(elements: usize) -> Self {
|
|
let data = vec![0usize; elements.div_ceil(usize::BITS as usize)];
|
|
Self {
|
|
elements,
|
|
data,
|
|
core: BitMapCore::new(),
|
|
}
|
|
}
|
|
|
|
pub fn bitand_assign(&mut self, rhs: &Self) {
|
|
for i in 0..rhs.data.len() {
|
|
self.data[i] &= rhs.data[i];
|
|
}
|
|
}
|
|
|
|
pub fn data(&self) -> &[usize] {
|
|
&self.data
|
|
}
|
|
}
|
|
|
|
impl BitMapOps<usize> for AllocBitmap {
|
|
#[inline]
|
|
fn get(&self, index: usize) -> Option<bool> {
|
|
return self.core.get(self.elements, &self.data, index);
|
|
}
|
|
|
|
#[inline]
|
|
fn set(&mut self, index: usize, value: bool) -> Option<bool> {
|
|
return self.core.set(self.elements, &mut self.data, index, value);
|
|
}
|
|
|
|
#[inline]
|
|
fn len(&self) -> usize {
|
|
self.elements
|
|
}
|
|
|
|
#[inline]
|
|
fn size(&self) -> usize {
|
|
self.data.len() * core::mem::size_of::<usize>()
|
|
}
|
|
|
|
#[inline]
|
|
fn first_index(&self) -> Option<usize> {
|
|
self.core.first_index(&self.data)
|
|
}
|
|
|
|
#[inline]
|
|
fn first_false_index(&self) -> Option<usize> {
|
|
self.core.first_false_index(self.elements, &self.data)
|
|
}
|
|
|
|
#[inline]
|
|
fn last_index(&self) -> Option<usize> {
|
|
self.core.last_index(self.elements, &self.data)
|
|
}
|
|
|
|
#[inline]
|
|
fn last_false_index(&self) -> Option<usize> {
|
|
self.core.last_false_index(self.elements, &self.data)
|
|
}
|
|
|
|
#[inline]
|
|
fn next_index(&self, index: usize) -> Option<usize> {
|
|
self.core.next_index(self.elements, &self.data, index)
|
|
}
|
|
|
|
#[inline]
|
|
fn next_false_index(&self, index: usize) -> Option<usize> {
|
|
self.core.next_false_index(self.elements, &self.data, index)
|
|
}
|
|
|
|
#[inline]
|
|
fn prev_index(&self, index: usize) -> Option<usize> {
|
|
self.core.prev_index(self.elements, &self.data, index)
|
|
}
|
|
|
|
#[inline]
|
|
fn prev_false_index(&self, index: usize) -> Option<usize> {
|
|
self.core.prev_false_index(self.elements, &self.data, index)
|
|
}
|
|
|
|
#[inline]
|
|
fn invert(&mut self) {
|
|
self.core.invert(self.elements, &mut self.data);
|
|
}
|
|
|
|
#[inline]
|
|
fn is_full(&self) -> bool {
|
|
self.core.is_full(self.elements, &self.data)
|
|
}
|
|
|
|
#[inline]
|
|
fn is_empty(&self) -> bool {
|
|
self.core.is_empty(&self.data)
|
|
}
|
|
|
|
#[inline]
|
|
unsafe fn as_bytes(&self) -> &[u8] {
|
|
core::slice::from_raw_parts(
|
|
self.data.as_ptr() as *const u8,
|
|
core::mem::size_of::<Self>(),
|
|
)
|
|
}
|
|
|
|
fn set_all(&mut self, value: bool) {
|
|
self.core.set_all(self.elements, &mut self.data, value);
|
|
}
|
|
}
|
|
|
|
impl BitAnd for &AllocBitmap {
|
|
type Output = AllocBitmap;
|
|
|
|
fn bitand(self, rhs: Self) -> Self::Output {
|
|
let mut result = AllocBitmap::new(self.elements);
|
|
for i in 0..rhs.data.len() {
|
|
result.data[i] = self.data[i] & rhs.data[i];
|
|
}
|
|
result
|
|
}
|
|
}
|
|
|
|
impl BitAnd for AllocBitmap {
|
|
type Output = AllocBitmap;
|
|
|
|
fn bitand(self, rhs: Self) -> Self::Output {
|
|
&self & &rhs
|
|
}
|
|
}
|