1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use super::{alloc_kernel_object_id, KernelObject, KernelObjectId};
use alloc::sync::Arc;
use hal::memory::{Flags, PAddr, VAddr};
use seed::boot_info::Segment;
pub struct MemoryObject {
pub id: KernelObjectId,
pub owner: KernelObjectId,
pub virtual_address: Option<VAddr>,
pub physical_address: PAddr,
pub size: usize,
pub flags: Flags,
}
impl MemoryObject {
pub fn new(
owner: KernelObjectId,
virtual_address: Option<VAddr>,
physical_address: PAddr,
size: usize,
flags: Flags,
) -> Arc<MemoryObject> {
Arc::new(MemoryObject {
id: alloc_kernel_object_id(),
owner,
virtual_address,
physical_address,
size,
flags,
})
}
pub fn from_boot_info(owner: KernelObjectId, segment: &Segment) -> Arc<MemoryObject> {
Arc::new(MemoryObject {
id: alloc_kernel_object_id(),
owner,
virtual_address: Some(segment.virtual_address),
physical_address: segment.physical_address,
size: segment.size,
flags: segment.flags,
})
}
}
impl KernelObject for MemoryObject {
fn id(&self) -> KernelObjectId {
self.id
}
}