Skip to content

Commit 9261cb7

Browse files
committed
Revert "Merge branch 'patch-add-file-mapping' into patch-fix-mmap"
This reverts commit 8eb687c, reversing changes made to 33e9f0b.
1 parent 8eb687c commit 9261cb7

File tree

20 files changed

+117
-396
lines changed

20 files changed

+117
-396
lines changed

kernel/src/arch/riscv64/mm/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212
page_frame::{FrameAllocator, PageFrameCount, PageFrameUsage, PhysPageFrame},
1313
},
1414
kernel_mapper::KernelMapper,
15-
page::{EntryFlags, PageEntry, PAGE_1G_SHIFT},
15+
page::{PageEntry, PageFlags, PAGE_1G_SHIFT},
1616
ucontext::UserMapper,
1717
MemoryManagementArch, PageTableKind, PhysAddr, VirtAddr,
1818
},
@@ -270,8 +270,8 @@ impl VirtAddr {
270270
}
271271

272272
/// 获取内核地址默认的页面标志
273-
pub unsafe fn kernel_page_flags<A: MemoryManagementArch>(_virt: VirtAddr) -> EntryFlags<A> {
274-
EntryFlags::from_data(RiscV64MMArch::ENTRY_FLAG_DEFAULT_PAGE)
273+
pub unsafe fn kernel_page_flags<A: MemoryManagementArch>(_virt: VirtAddr) -> PageFlags<A> {
274+
PageFlags::from_data(RiscV64MMArch::ENTRY_FLAG_DEFAULT_PAGE)
275275
.set_user(false)
276276
.set_execute(true)
277277
}

kernel/src/arch/x86_64/kvm/vmx/ept.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::arch::mm::LockedFrameAllocator;
22
use crate::arch::mm::PageMapper;
33
use crate::arch::MMArch;
4-
use crate::mm::page::EntryFlags;
4+
use crate::mm::page::PageFlags;
55
use crate::mm::{PageTableKind, PhysAddr, VirtAddr};
66
use crate::smp::core::smp_get_processor_id;
77
use crate::smp::cpu::AtomicProcessorId;
@@ -92,7 +92,7 @@ impl EptMapper {
9292
&mut self,
9393
gpa: u64,
9494
hpa: u64,
95-
flags: EntryFlags<MMArch>,
95+
flags: PageFlags<MMArch>,
9696
) -> Result<(), SystemError> {
9797
if self.readonly {
9898
return Err(SystemError::EAGAIN_OR_EWOULDBLOCK);

kernel/src/arch/x86_64/kvm/vmx/mmu.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{
22
arch::kvm::vmx::ept::EptMapper,
33
libs::mutex::Mutex,
4-
mm::{page::EntryFlags, syscall::ProtFlags},
4+
mm::{page::PageFlags, syscall::ProtFlags},
55
virt::kvm::host_mem::{__gfn_to_pfn, kvm_vcpu_gfn_to_memslot, PAGE_MASK, PAGE_SHIFT},
66
};
77
use bitfield_struct::bitfield;
@@ -218,7 +218,7 @@ pub fn __direct_map(
218218
}
219219
// 把gpa映射到hpa
220220
let mut ept_mapper = EptMapper::lock();
221-
let page_flags = EntryFlags::from_prot_flags(ProtFlags::from_bits_truncate(0x7_u64), false);
221+
let page_flags = PageFlags::from_prot_flags(ProtFlags::from_bits_truncate(0x7_u64), false);
222222
unsafe {
223223
assert!(ept_mapper.walk(gpa, pfn << PAGE_SHIFT, page_flags).is_ok());
224224
}

kernel/src/arch/x86_64/mm/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use crate::{
2828
};
2929

3030
use crate::mm::kernel_mapper::KernelMapper;
31-
use crate::mm::page::{EntryFlags, PageEntry, PAGE_1G_SHIFT};
31+
use crate::mm::page::{PageEntry, PageFlags, PAGE_1G_SHIFT};
3232
use crate::mm::{MemoryManagementArch, PageTableKind, PhysAddr, VirtAddr};
3333

3434
use system_error::SystemError;
@@ -650,17 +650,17 @@ impl FrameAllocator for LockedFrameAllocator {
650650
}
651651

652652
/// 获取内核地址默认的页面标志
653-
pub unsafe fn kernel_page_flags<A: MemoryManagementArch>(virt: VirtAddr) -> EntryFlags<A> {
653+
pub unsafe fn kernel_page_flags<A: MemoryManagementArch>(virt: VirtAddr) -> PageFlags<A> {
654654
let info: X86_64MMBootstrapInfo = BOOTSTRAP_MM_INFO.unwrap();
655655

656656
if virt.data() >= info.kernel_code_start && virt.data() < info.kernel_code_end {
657657
// Remap kernel code execute
658-
return EntryFlags::new().set_execute(true).set_write(true);
658+
return PageFlags::new().set_execute(true).set_write(true);
659659
} else if virt.data() >= info.kernel_data_end && virt.data() < info.kernel_rodata_end {
660660
// Remap kernel rodata read only
661-
return EntryFlags::new().set_execute(true);
661+
return PageFlags::new().set_execute(true);
662662
} else {
663-
return EntryFlags::new().set_write(true).set_execute(true);
663+
return PageFlags::new().set_write(true).set_execute(true);
664664
}
665665
}
666666

kernel/src/driver/net/dma.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::arch::mm::kernel_page_flags;
33
use crate::arch::MMArch;
44

55
use crate::mm::kernel_mapper::KernelMapper;
6-
use crate::mm::page::{page_manager_lock_irqsave, EntryFlags};
6+
use crate::mm::page::{page_manager_lock_irqsave, PageFlags};
77
use crate::mm::{
88
allocator::page_frame::{
99
allocate_page_frames, deallocate_page_frames, PageFrameCount, PhysPageFrame,
@@ -25,7 +25,7 @@ pub fn dma_alloc(pages: usize) -> (usize, NonNull<u8>) {
2525
// 清空这块区域,防止出现脏数据
2626
core::ptr::write_bytes(virt.data() as *mut u8, 0, count.data() * MMArch::PAGE_SIZE);
2727

28-
let dma_flags: EntryFlags<MMArch> = EntryFlags::mmio_flags();
28+
let dma_flags: PageFlags<MMArch> = PageFlags::mmio_flags();
2929

3030
let mut kernel_mapper = KernelMapper::lock();
3131
let kernel_mapper = kernel_mapper.as_mut().unwrap();

kernel/src/driver/video/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010
spinlock::SpinLock,
1111
},
1212
mm::{
13-
allocator::page_frame::PageFrameCount, kernel_mapper::KernelMapper, page::EntryFlags,
13+
allocator::page_frame::PageFrameCount, kernel_mapper::KernelMapper, page::PageFlags,
1414
MemoryManagementArch,
1515
},
1616
time::timer::{Timer, TimerFunction},
@@ -95,7 +95,7 @@ impl VideoRefreshManager {
9595
let count = PageFrameCount::new(
9696
page_align_up(frame_buffer_info_guard.buf_size()) / MMArch::PAGE_SIZE,
9797
);
98-
let page_flags: EntryFlags<MMArch> = EntryFlags::new().set_execute(true).set_write(true);
98+
let page_flags: PageFlags<MMArch> = PageFlags::new().set_execute(true).set_write(true);
9999

100100
let mut kernel_mapper = KernelMapper::lock();
101101
let mut kernel_mapper = kernel_mapper.as_mut();

kernel/src/driver/virtio/virtio_impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::arch::mm::kernel_page_flags;
33
use crate::arch::MMArch;
44

55
use crate::mm::kernel_mapper::KernelMapper;
6-
use crate::mm::page::{page_manager_lock_irqsave, EntryFlags};
6+
use crate::mm::page::{page_manager_lock_irqsave, PageFlags};
77
use crate::mm::{
88
allocator::page_frame::{
99
allocate_page_frames, deallocate_page_frames, PageFrameCount, PhysPageFrame,
@@ -32,7 +32,7 @@ unsafe impl Hal for HalImpl {
3232
// 清空这块区域,防止出现脏数据
3333
core::ptr::write_bytes(virt.data() as *mut u8, 0, count.data() * MMArch::PAGE_SIZE);
3434

35-
let dma_flags: EntryFlags<MMArch> = EntryFlags::mmio_flags();
35+
let dma_flags: PageFlags<MMArch> = PageFlags::mmio_flags();
3636

3737
let mut kernel_mapper = KernelMapper::lock();
3838
let kernel_mapper = kernel_mapper.as_mut().unwrap();

kernel/src/filesystem/vfs/file.rs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use alloc::{
55
sync::{Arc, Weak},
66
vec::Vec,
77
};
8-
use hashbrown::HashMap;
98
use log::error;
109
use system_error::SystemError;
1110

@@ -17,7 +16,6 @@ use crate::{
1716
filesystem::procfs::ProcfsFilePrivateData,
1817
ipc::pipe::{LockedPipeInode, PipeFsPrivateData},
1918
libs::{rwlock::RwLock, spinlock::SpinLock},
20-
mm::page::Page,
2119
net::{
2220
event_poll::{EPollItem, EPollPrivateData, EventPoll},
2321
socket::SocketInode,
@@ -120,45 +118,6 @@ impl FileMode {
120118
return self.bits() & FileMode::O_ACCMODE.bits();
121119
}
122120
}
123-
124-
#[allow(dead_code)]
125-
pub struct PageCache {
126-
inode_ref: Weak<dyn IndexNode>,
127-
map: HashMap<usize, Arc<Page>>,
128-
}
129-
130-
impl PageCache {
131-
pub fn new(inode_ref: Weak<dyn IndexNode>) -> PageCache {
132-
Self {
133-
inode_ref,
134-
map: HashMap::new(),
135-
}
136-
}
137-
138-
pub fn add_page(&mut self, offset: usize, page: Arc<Page>) {
139-
self.map.insert(offset, page);
140-
}
141-
142-
pub fn get_page(&self, offset: usize) -> Option<Arc<Page>> {
143-
self.map.get(&offset).cloned()
144-
}
145-
146-
// pub fn get_pages(&self, start_pgoff: usize, end_pgoff: usize) -> Vec<Arc<Page>> {
147-
// let mut vec = Vec::new();
148-
// for pgoff in start_pgoff..=end_pgoff {
149-
// if let Some(page) = self.map.get(&pgoff) {
150-
// vec.push(page.clone());
151-
// }
152-
// }
153-
// vec
154-
// }
155-
}
156-
157-
pub trait PageCacheOperations: IndexNode {
158-
fn write_page(&self, page: Page);
159-
fn read_ahead(&self);
160-
}
161-
162121
/// @brief 抽象文件结构体
163122
#[derive(Debug)]
164123
pub struct File {

kernel/src/filesystem/vfs/mod.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@ use crate::{
2323
time::PosixTimeSpec,
2424
};
2525

26-
use self::{
27-
core::generate_inode_id,
28-
file::{FileMode, PageCache},
29-
syscall::ModeType,
30-
utils::DName,
31-
};
26+
use self::{core::generate_inode_id, file::FileMode, syscall::ModeType, utils::DName};
3227
pub use self::{core::ROOT_INODE, file::FilePrivateData, mount::MountFS};
3328

3429
/// vfs容许的最大的路径名称长度
@@ -553,10 +548,6 @@ pub trait IndexNode: Any + Sync + Send + Debug + CastFromSync {
553548
fn parent(&self) -> Result<Arc<dyn IndexNode>, SystemError> {
554549
return self.find("..");
555550
}
556-
557-
fn page_cache(&self) -> Option<PageCache> {
558-
None
559-
}
560551
}
561552

562553
impl DowncastArc for dyn IndexNode {

kernel/src/ipc/shm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl ShmManager {
165165
let mut page_manager_guard = page_manager_lock_irqsave();
166166
let mut cur_phys = PhysPageFrame::new(phys_page.0);
167167
for _ in 0..page_count.data() {
168-
let mut page = Page::new(true, cur_phys);
168+
let mut page = Page::new(true);
169169
page.set_shm_id(shm_id);
170170
let paddr = cur_phys.phys_address();
171171
page_manager_guard.insert(paddr, page);

0 commit comments

Comments
 (0)